Java - Custom shaped draggable JFrame

前端 未结 2 1014
不知归路
不知归路 2021-01-26 05:58

so I made a custom shaped JFrame using setShape(s); and I got it to look how I wanted the problem when you set the JFrame to be undecorated you can\'t drag the Fram

2条回答
  •  失恋的感觉
    2021-01-26 06:39

    I think your problem is worrying about the shape of the frame when executing the mouseDragged. I don't think you need to worry about that.

    If you just change your method to the below, it works. Test it out.

    void updateFrameCoords(MouseEvent e) {
        setLocation(getLocation().x + e.getX() - initialPressedX,
                    getLocation().y + e.getY() - initialPressedY);
    }
    

提交回复
热议问题