A
A
Anton @ Lyalin2016-11-05 14:20:34
Java
Anton @ Lyalin, 2016-11-05 14:20:34

How to open another window after closing the first one???

The first window opens, I enter data, by pressing the button the data is recorded and closed;
How to make the second, main, window open after closing the first one??
There are two classes:
This is a data entry window, after which it closes.

public miniframeClass(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(200, 160);
        setLayout(null);
        setResizable(false);
        setVisible(true);

        JLabel jLabelWeight = new JLabel("Weight");
        jLabelWeight.setBounds(15, 5, 90, 20);

        JLabel jLabelHeight = new JLabel("Height");
        jLabelHeight.setBounds(120, 5, 90, 20);

        JTextField jTextFieldWeight = new JTextField();
        jTextFieldWeight.setBounds(5, 30, 90, 20);
        
        JTextField jTextFieldHeight = new JTextField();
        jTextFieldHeight.setBounds(105, 30, 90, 20);
        
        JButton jButton = new JButton("OK");
        jButton.setBounds(40, 70, 120, 30);

        add(jLabelWeight);
        add(jLabelHeight);
        add(jTextFieldWeight);
        add(jTextFieldHeight);
        add(jButton);
        repaint();

        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    mainClass.getWeightHeight(jTextFieldWeight, jTextFieldHeight);
                    System.out.print(Weight + " " + Height);
                    dispose();
                }catch (Exception err){
                    JOptionPane.showMessageDialog(null, "Ошибка ввода\n" + err);
                }
            }
        });
    }

And I need the next window to be created after the first one.
public frameClass(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(500, 500);
        setVisible(true);
        setResizable(false);

    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question