this.setUndecorated(true); // 删除掉关闭按键
/**
* 添加拖动窗口的功能
*/
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);
}
}
});
java设置窗体去掉关闭按钮以及拖动功能窗口
最新推荐文章于 2021-03-02 14:13:02 发布