A
A
Anton @ Lyalin2016-11-09 13:51:48
Java
Anton @ Lyalin, 2016-11-09 13:51:48

How can I make the first window not close when the second one is closed?

I create the main window, I placed a button on it, by pressing which a new window is created.

jButtonSee.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableClass table = new tableClass();
            }
        });

How can I make the first window not close??
The window code of the second window. The first one is the same, only with a button:
public tableClass(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setSize(new Dimension(500, 500));
        setTitle("JTable");
        setLayout(new FlowLayout());

        JTable jTable = new JTable();
        JScrollPane jScrollPane = new JScrollPane(jTable);
        jScrollPane.setSize(450, 400);
        setVisible(true);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton @ Lyalin, 2016-11-09
@toxa_1995

I'll add the main window to main:

public static void main(String[] args){
        new frameClass();
    }

Solved my problem, the first window is JFrame.EXIT_ON_CLOSE and the second window is JFrame.DISPOSE_ONCLOSE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question