本帖最后由 cxiyue 于 2013-06-10 00:28:26 编辑

解决方案 »

  1.   

    this.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    isDraging = true;
    xx = e.getX();
    yy = e.getY();
    } public void mouseReleased(MouseEvent e) {
    isDraging = false;
    }
    });
    this.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) {
    if (isDraging) {
    int left = getLocation().x;
    int top = getLocation().y;
    setLocation(left + e.getX() - xx, top + e.getY() - yy);
    }
    } });