2017-08-08 149 views
0

由于某种原因,我的JFrame没有关闭按钮?我试着改变代码,但它似乎没有工作。JFrame没有关闭窗口?

public NewJFrame() 
{ 
    this.setUndecorated(true); 
    this.setVisible(true); 


    initComponents(); 

    this.setDefaultCloseOperation(NewJFrame.EXIT_ON_CLOSE); 
    Toolkit tk = Toolkit.getDefaultToolkit(); 
    int x = (int) tk.getScreenSize().getWidth(); 
    int y = (int) tk.getScreenSize().getHeight(); 
    this.setSize(x,y); 
} 
+1

尝试用鼠标手动调整大小 - 可能是关闭按钮只是隐藏 –

+0

不能调整JFrame的大小。 – Swiper

+0

类似的问题已回答[here](https://stackoverflow.com/questions/7799940/jframe-exit-on-close-java) – firefighter

回答

3

关闭按钮是你

this.setUndecorated(true); 

删除如果你想回去,你就必须删除此行或创建自己的一个装饰品之一。

+0

感谢它的工作,这样一个小错误。 – Swiper

+0

@Swiper你能接受答案吗? –