import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Hiireklahvid extends Applet implements MouseListener{ int x1=100, x2=200; int y1=100, y2=100; public Hiireklahvid(){ addMouseListener(this); } public void paint(Graphics g){ g.setColor(Color.red); g.drawRect(x1-5, y1-5, 10, 10); g.setColor(Color.green); g.drawRect(x2-5, y2-5, 10, 10); } public void mousePressed(MouseEvent e){ if(e.isPopupTrigger()){ x2=e.getX(); y2=e.getY(); } else { x1=e.getX(); y1=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[] argumendid){ Frame f=new Frame(); f.add(new Hiireklahvid()); f.setSize(200, 200); f.setVisible(true); } }