Hi there,

I am new in java, I have school problem stands like this:

Write a code for drawing two lines. By every click, a segment should be drawn which connect the current location with the preview one. The coordinates of the Lines must be stored at Line.txt. Put Buttons for clearing the display, writing the coordinates of the lines and calculating the distance between the lines.

my current code is as follows, but i am missing more than the half of the program, pls any help!!!

the code:

//public void mousePressed(MouseEvent e){}
//public void mouseClicked(MouseEvent e){}
//public void mouseEntered(MouseEvent e){}
//public void mouseExited(MouseEvent e){}
//public void mouseReleased(MouseEvent e){}
//Interface uses the keyword "implements" in the class declaration when it is being used You must implemnet
// all methods of an interface. You can leave empty any unNeeded methods.
//e.g.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.io.*;

public class MouseTest extends Applet implements MouseListener{

int x, y ;
String tracer;
public MouseTest(){
addMouseListener(this);
setBackground(Color.red);
setPreferredSize(new Dimension(600,600));
}
public void mousePressed(MouseEvent e){
x = e.getX() - 10;
y = e.getY() - 10;
tracer = " x = " + x + " y = " + y;
// repaint the applet
repaint();
}
// dont use these so leave them empty
public void mouseClicked(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
// paint method
public void paint(Graphics g){
g.drawString(tracer, 100 , 100);
g.drawOval(x,y,20,20);
}
public static void main(String[] args) {
JFrame windo = new JFrame("TESKA ZADACA");
windo.add(new MouseTest());
windo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
windo.pack();
windo.setVisible(true);
}
}