class Node extends JLabel implements MouseListener{
int x,y;
public Node(int x, int y){
super(""); //or can be an icon
setSize(2,2);
this.x=x;
this.y=y;
setLocation(x,y);
addMouseListener(this);
}
public int getX() ...getY()....
public void mouseDragged(MouseEvent e){
setLocation(e.getPoint());
}
...... //other MouseListener methods
}abstract class MyShape{
public abstract void draw(Graphics g);
}class Line extends MyShape{
Node[] nodes=new Node[2];
public Line(x1,y1,x2,y2){
nodes[0]=new Node(x1,y1);....
}
public void draw(Graphics g){
g.drawLine(nodes[0].getX(),nodes[0].getY(),.....);
}
}IT'S JUST AN IDEA, HASN'T BEEN TESTED
int x,y;
public Node(int x, int y){
super(""); //or can be an icon
setSize(2,2);
this.x=x;
this.y=y;
setLocation(x,y);
addMouseListener(this);
}
public int getX() ...getY()....
public void mouseDragged(MouseEvent e){
setLocation(e.getPoint());
}
...... //other MouseListener methods
}abstract class MyShape{
public abstract void draw(Graphics g);
}class Line extends MyShape{
Node[] nodes=new Node[2];
public Line(x1,y1,x2,y2){
nodes[0]=new Node(x1,y1);....
}
public void draw(Graphics g){
g.drawLine(nodes[0].getX(),nodes[0].getY(),.....);
}
}IT'S JUST AN IDEA, HASN'T BEEN TESTED
java.awt.dnd.*;