import java.applet.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class Jooned1 extends Applet implements MouseListener{ Vector hoidla=new Vector(); int algx, algy; public Jooned1(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ algx=e.getX(); algy=e.getY(); } public void mouseReleased(MouseEvent e){ hoidla.addElement(new Joon(algx, algy, e.getX(), e.getY())); repaint(); } public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void paint(Graphics g){ Enumeration e=hoidla.elements(); while(e.hasMoreElements()){ Joon j=(Joon)e.nextElement(); g.drawLine(j.x1, j.y1, j.x2, j.y2); } } public static void main(String[] arg){ Frame f=new Frame(); f.add(new Jooned1()); f.setSize(300, 300); f.setVisible(true); } class Joon{ int x1, y1, x2, y2; Joon(int ux1, int uy1, int ux2, int uy2){ x1=ux1; y1=uy1; x2=ux2; y2=uy2; } } }