java设置窗体去掉关闭按钮以及拖动功能窗口

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)