[英]How call a JFrame from my Application Window SWT Builder
Here is my code in my ApplicationWindow. 这是我的ApplicationWindow中的代码。 I have a widgetSelected happening for a bottom called "Welcome" that I want to open a new window with text, which I already have programmed.
我在一个名为“ Welcome”的底部发生了一个widgetSelected事件,我想用一个已经编程的文本打开一个新窗口。
//Welcome was clicked
mntmWelcome.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Welcome2 newWindow = new Welcome2();
newWindow.setVisible(true);
}
});
And the welcome is a JDialog
only showing some text and stuff, but when I use this the program crashes and I get 欢迎使用的是一个
JDialog
仅显示一些文本和内容,但是当我使用它时,程序崩溃了,我得到了
java.lang.IllegalArgumentException: defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE
java.lang.IllegalArgumentException:defaultCloseOperation必须是以下之一:DO_NOTHING_ON_CLOSE,HIDE_ON_CLOSE或DISPOSE_ON_CLOSE
and I have no idea where to set this, i tried within the override but the window never opens. 我不知道在哪里设置,我在覆盖中尝试过,但窗口从未打开。 I just want it to open and the previous window should still be there behind.
我只想打开它,并且前面的窗口应该仍然在后面。 How can I solve this?
我该如何解决?
Try adding this: 尝试添加以下内容:
newWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Please, refer to: https://chortle.ccsu.edu/java5/Notes/chap56/ch56_9.html and read this https://docs.oracle.com/javase/7/docs/api/javax/swing/WindowConstants.html . 请参考: https : //chortle.ccsu.edu/java5/Notes/chap56/ch56_9.html并阅读此https://docs.oracle.com/javase/7/docs/api/javax/swing/WindowConstants .html 。
Documentations are really useful for beginners. 文档对于初学者真的很有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.