import javax.swing.*; import java.awt.*; import java.util.*; public class Tahvel extends JPanel{ java.util.List kujundid=new ArrayList(); public Tahvel(){ kujundid.add(new Ristkylik(10, 10, 40, 30)); kujundid.add(new Ristkylik(100, 10, 40, 50)); } public void paintComponent(Graphics g){ super.paintComponent(g); for(Ristkylik r: kujundid){ r.joonista(g); } } public Ristkylik leiaKujundKohal(int hx, int hy){ for(Ristkylik r: kujundid){ if(r.kasPihtas(hx, hy)){return r;} } return null; } public static void main(String[] arg){ JFrame f=new JFrame(); f.getContentPane().add(new Tahvel()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }