import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class HiirPallid extends JPanel implements MouseListener{ java.util.List pallid=new ArrayList(); public HiirPallid(){ addMouseListener(this); } public void paintComponent(Graphics g){ super.paintComponent(g); for(Pall p: pallid){ p.joonista(g); } } public void mousePressed(MouseEvent e){ pallid.add(new Pall(e.getX(), e.getY())); repaint(); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] arg){ JFrame f=new JFrame(); f.getContentPane().add(new HiirPallid()); f.setSize(400, 300); f.setVisible(true); } }