import java.awt.Frame;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class TestCopy implements MouseListener{
Frame f;
int x1,y1,x2,y2;
Graphics g;
TestCopy(){
f=new Frame();
f.addMouseListener(this);
f.setSize(300,200);
f.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new TestCopy();
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
x1=e.getX();y1=e.getY();
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
x2=e.getX();y2=e.getY();
g=f.getGraphics();
g.drawLine(x1, y1, x2, y2);
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
}