import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SonaPaigutus3 extends JApplet implements MouseListener{ Sona s1=new Sona("Kauss", 50, 30); public SonaPaigutus3(){ addMouseListener(this); } public void paint(Graphics g){ super.paint(g); s1.joonista(g); } public void mousePressed(MouseEvent e){ s1.muudaAsukoht(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("Sõna paigutus"); f.getContentPane().add(new SonaPaigutus3()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }