import java.awt.*; public class Varvid extends Frame { public Varvid() { setTitle("Värvid"); setLayout(new FlowLayout()); add(new Button("Kollane")); add(new Button("Sinine")); add(new Button("Oranz")); add(new Button("Roheline")); add(new Button("Roosa")); add(new Button("Punane")); add(new Button("Ilus värv")); } public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_DESTROY) System.exit(0); return super.handleEvent(evt); } public boolean action(Event evt, Object arg) { if (arg.equals("Kollane")) { setBackground(Color.yellow); repaint(); } else if (arg.equals("Sinine")) { setBackground(Color.blue); repaint(); } else if (arg.equals("Oranz")) { setBackground(Color.orange); repaint(); } else if (arg.equals("Roheline")) { setBackground(Color.green); repaint(); } else if (arg.equals("Roosa")) { setBackground(Color.pink); repaint(); } else if (arg.equals("Punane")) { setBackground(Color.red); repaint(); } else if (arg.equals("Ilus värv")) { setBackground(Color.cyan); repaint(); } else return false; repaint(); return true; } public static void main(String[] args) { Frame f = new Varvid(); f.resize(400, 200); f.show(); } }