public void paint(Graphics g) {
setBackground(Color.black);
g.setColor(Color.black);
g.fillOval(5,5,80,80);
g.fillRect(5,5,80,80);
g.setColor(currentColor);
if ( shapeSpec.getText(). equals("oval"))
g.fillOval(5,5,80,80);
else
g.fillRect(5,5,80,80);
}
public void actionPerformed
(ActionEvent e) {
if (e.getSource()==red)
currentColor =
new Color(255,0,0);
else
currentColor =
new Color(0,255,0);
repaint();
}
Button red, green;
TextField shapeSpec;
Color currentColor;
}
Previous slide | Next slide | Back to first slide | View graphic version |