FileDocCategorySizeDatePackage
Blob3.javaAPI DocExample2575Thu Feb 03 08:18:02 GMT 2000None

Blob3

public class Blob3 extends Frame

Fields Summary
private Picture
picture
Constructors Summary
public Blob3()

  setTitle( "Blob3" ); 
      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 );
      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 Blob3();
   
public voidpaint(java.awt.Graphics g)

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

  paint( g );