import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SonaPaigutus2 extends JApplet implements MouseListener{ String sona="Tere"; int x=50; int y=100; public SonaPaigutus2(){ addMouseListener(this); } public void paint(Graphics g){ super.paint(g); g.drawString(sona, x, y); } public void mousePressed(MouseEvent e){ x=e.getX(); y=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 SonaPaigutus2()); f.setSize(400, 300); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }