import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Joonis5 extends JPanel implements MouseListener{ int vasakserv=10; int ylaserv=40; int ruudusuurus=30; int veergudearv=8; int ridadearv=8; int nupuveerg=2; int nupurida=4; public Joonis5(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ nupuveerg=(e.getX()-vasakserv)/ruudusuurus; nupurida=(e.getY()-ylaserv)/ruudusuurus; repaint(); } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void paintComponent(Graphics g){ super.paintComponent(g); //Kutsu välja JPaneli sama käsklus int ruudulaius=(this.getWidth()-2*vasakserv)/veergudearv; int ruudukorgus=(this.getHeight()-ylaserv)/ridadearv; if(ruudulaius