How to make a JFrame button open another JFrame class in Netbeans?

Ultrabyte picture Ultrabyte · Jul 14, 2013 · Viewed 235.6k times · Source

I have a JFrame class and it was made in the design section on Netbeans. I am trying to make a log in button that takes closes the current frame and opens another, is there anyway I can do that?

I have tried:

JFrame frame = new JFrame(); 

But I want it to be editable in the design section!

Answer

Gokul E picture Gokul E · Jul 14, 2013

Double Click the Login Button in the NETBEANS or add the Event Listener on Click Event (ActionListener)

btnLogin.addActionListener(new ActionListener() 
{
    public void actionPerformed(ActionEvent e) {
        this.setVisible(false);
        new FrmMain().setVisible(true); // Main Form to show after the Login Form..
    }
});