[英]How Can A Program Close A GUI Without The Program Ending
Title says it all, before anyone says that there is a thread about closing a GUI without the program end then hold on a second. 标题说了这一切,然后才有人说在没有程序结束的情况下关闭GUI的线程,然后稍等片刻。
My question is that, how can the PROGRAM close a GUI and not the user so it can progress onto another frame. 我的问题是,程序如何关闭GUI而不关闭用户,以便它可以前进到另一个框架。
If this question below is about a Swing GUI: 如果以下问题与Swing GUI有关:
My question is that, how can the PROGRAM close a GUI and not the user so it can progress onto another frame.
我的问题是,程序如何关闭GUI而不关闭用户,以便它可以前进到另一个框架。
Then this question can be answered thusly: 这样就可以回答这个问题:
JFrame.DO_NOTHING_ON_CLOSE
. JFrame.DO_NOTHING_ON_CLOSE
默认关闭操作属性设置为JFrame.DO_NOTHING_ON_CLOSE
。 close()
or setVisible(false)
on the window. close()
或setVisible(false)
来关闭任何窗口。 ie, 即
myJFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
But having said that, the question in fact should be answered: 但话虽如此,实际上应该回答这个问题:
Again, note that your question as originally stated is very incomplete, and in the future, you will want to tell us any and all relevant libraries that are involved, here the Swing library since the question is likely essentially a Swing question. 同样,请注意,您最初提出的问题非常不完整,将来,您将想告诉我们所涉及的所有相关库,这里是Swing库,因为该问题本质上可能是Swing问题。 You will also want to show some code and explain exactly where you might be stuck.
您还将需要显示一些代码并确切说明您可能会遇到的问题。 Usually the better the question, the better the answers you'll see.
通常,问题越好,您看到的答案就越好。 For instance, with more information and code, we could show you some code to get you started with a CardLayout.
例如,借助更多的信息和代码,我们可以向您展示一些代码,以帮助您开始使用CardLayout。
java.awt.Window aTopLevelGUI; // Normally referenced as a JWindow, but this is what impls setVisible(boolean)
// To close the window:
aTopLevelGUI.setVisible(false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.