简体   繁体   中英

How call a JFrame from my Application Window SWT Builder

Here is my code in my 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 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

java.lang.IllegalArgumentException: defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or 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 .

Documentations are really useful for beginners.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM