FileDocCategorySizeDatePackage
Blob4.javaAPI DocExample3101Thu Feb 03 08:18:02 GMT 2000None

Blob4

public class Blob4 extends Frame

Fields Summary
private Picture
picture
Constructors Summary
public Blob4()

  setTitle( "Blob4" ); 
      setSize( 300, 300 );
      picture = new Picture();

      Panel controls = new Panel();
      controls.setLayout( new FlowLayout( FlowLayout.LEFT ) );

      Choice colours = new Choice();
      colours.addItem( "Red" );
      colours.addItem( "Blue" );
      colours.addItem( "Green" );
      // and so on !
      colours.addItemListener( new ItemListener() {
         public void itemStateChanged( ItemEvent e )
         {  picture.setColour( (String)(e.getItem()) );
         }
      });
      controls.add( colours );
      
      TextField size = new TextField( "10", 3 );
      size.addActionListener( new ActionListener() {
         public void actionPerformed( ActionEvent e )
         {  String s = e.getActionCommand();
            picture.setSize( Integer.parseInt( s.trim() ) );
         }
      });
      controls.add( new Label( " Size:" ) );
      controls.add( size );

      add( "North", controls );
            
      
      addMouseListener( new MouseAdapter() {
         public void mousePressed( MouseEvent e )
         {  picture.addBlob( e.getX(), e.getY() );
            repaint();
         }
      });
      
      addWindowListener( new WindowAdapter() {
         public void windowClosing( WindowEvent e )
         {  System.exit(0);
         }
      });
      
      setVisible( true ); 
   
Methods Summary
public static voidmain(java.lang.String[] args)

  new Blob4();
   
public voidpaint(java.awt.Graphics g)

  picture.paint( g );
   
public voidupdate(java.awt.Graphics g)

  paint( g );