import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
class MyLine{
private int x1;
private int y1;
private int x2;
private int y2;
public MyLine(int x1,int y1,int x2,int y2){
this.x1=x1;
this.y1=y1;
this.x2=x2;
this.y2=y2;
}
public void drawMe(Graphics g){
g.drawLine(x1,y1,x2,y2);
}
}
public class RedrawAllLineMoveModify extends Frame
{
int orgX;
int orgY;
int orgXIni;
int orgYIni;
int orgXEnd;
int orgYEnd;
boolean isSure = false;
boolean isFirst = true;

Vector vLines=new Vector();
public static void main(String [] args){
RedrawAllLineMoveModify f = new RedrawAllLineMoveModify();
f.init();
}
public void paint(Graphics g){
g.setColor(Color.red);
Enumeration e=vLines.elements();
while(e.hasMoreElements()){
MyLine ln=(MyLine)e.nextElement();
ln.drawMe(g);
}
}


 Graphics g = null;
public void init()
{
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
((Window)e.getSource()).dispose();
System.exit(0);
}
});
addMouseListener(new MouseAdapter(){

public void mousePressed(MouseEvent e)
{
orgX=orgXEnd=e.getX();
orgY=orgYEnd =e.getY();
    g=e.getComponent().getGraphics();

g.setColor(Color.red);
}
public void mouseReleased(MouseEvent e)
{
g.setPaintMode();

g.drawLine(orgX,orgY,e.getX(),e.getY());


vLines.add(new MyLine(orgX,orgY,e.getX(),e.getY()));
}

});         
this.addMouseMotionListener(new MouseMotionAdapter(){

public void mouseDragged(MouseEvent e)
{     
g.setXORMode(getBackground());
g.drawLine(orgX,orgY,orgXEnd ,orgYEnd);
orgXEnd = e.getX();
orgYEnd = e.getY();
 

g.setColor(Color.red); g.drawLine(orgX,orgY,orgXEnd ,orgYEnd);
System.out.println("helo");


}
});
this.setSize(300,300);
setVisible(true);
}
}如何将此程序改为绘制矩形的啊!!!!!