ft...这也难度极大?sorry 没空~~

解决方案 »

  1.   

    jigsaw(jigsaw),一副高手的样子,指点几句呗
      

  2.   


    public class Line {
        Point sp ;// start point
        Point ep ;// end point;   public Line(Point sp.Point ep) {
        ................
       }
       
        public boolean isFocus (Point p) {
           //参数p 从外部panel传入  看看这个p 是否再 直线上面
                          //(就是判断是否符合直线方程)
        }    public void draw(Graphics g) {
            //Line class 应该放在panel 里面  参数g 是panel进来的参数 
            g.drawLine(sp.x,sp.y,ep.x,ep.y);
        }    public void action(Point p) {
            if(isFocus (p)) {
                do............................
                如果鼠标再直线上面  促发事件
             }
        } 
    }
      

  3.   

    append :  Line 不需要extends Component,public class panel extend JPanel {
     .......................
      
        Line l = new Line(new Point(0,0),new Point(100,100));
       
        public void panitConponent(Graphics g) {
             super.panitConponent();
             1.draw(g);
        }}
    如果需要判断鼠标位置  则需要implemnts mouse 的interface 这个你应该会作吧