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 );