JPanel NullPointerException
Hi guys,
So I want to update some panels on my GUI when a button gets pressed.
I got action listener assigned and everything works - but.
When I click a button the code gets an Panel object. This is my panel.
Code:
public class LoginPane extends JPanel{
public LoginPane(){
JButton test = new JButton("Login test");
this.add(test);
}
}
The action listener calls this method:
Code:
public static void loginPanel(){
loginPane = new LoginPane();
[B]content.add(loginPane, BorderLayout.CENTER);[/B]
content.repaint();
content.updateUI();
}
I've set line to bold that errors out.
When I press a button, I get a compiler error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at GUI.MainFrame.loginPanel(MainFrame.java:77)
at Listeners.LoginListener.actionPerformed(LoginListe ner.java:14)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387) etc....
Any help would be appreciated.