import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.awt.event.*; import java.applet.*; public class Pind extends Applet implements ItemListener{ Area r1=new Area(new Rectangle2D.Float(20, 50, 100, 100)); Area r2=new Area(new Rectangle2D.Float(60, 60, 100, 70)); Choice valik=new Choice(); public Pind(){ valik.add("Ühend"); valik.add("Ühisosa"); valik.add("Vahe"); valik.add("Välistus"); add(valik); valik.addItemListener(this); } public void paint(Graphics g){ Area pind=new Area(); pind.add(r1); String s=valik.getSelectedItem(); if(s.equals("Ühend"))pind.add(r2); if(s.equals("Ühisosa"))pind.intersect(r2); if(s.equals("Vahe"))pind.subtract(r2); if(s.equals("Välistus"))pind.exclusiveOr(r2); Graphics2D g2=(Graphics2D)g; g2.setColor(Color.blue); g2.fill(pind); g2.setColor(Color.red); g2.draw(pind); } public void itemStateChanged(ItemEvent e){ repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Muster taustaks"); f.add(new Pind()); f.setSize(250, 250); f.setVisible(true); } }