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