import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Varviline extends Applet{ Choice valik=new Choice(); public void init(){ valik.addItem("sinine"); valik.add("punane"); valik.addItem("must"); add(valik); valik.addItemListener(new Valikukuular(this)); } public void paint(Graphics g){ g.setColor(Color.green); g.drawOval(50, 50, 20, 20); } } class Valikukuular implements ItemListener{ Varviline apl; public Valikukuular(Varviline v){ apl=v; } public void itemStateChanged(ItemEvent e){ Color c=Color.green; Choice valik=(Choice)e.getSource(); String varv=valik.getSelectedItem(); if(varv.equals("punane"))c=Color.red; if(varv.equals("sinine"))c=Color.blue; if(varv.equals("must"))c=Color.black; Graphics g=apl.getGraphics(); g.setColor(c); g.drawOval(50, 50, 20, 20); } }