I've got a main JFrame
that creates an instance of a basic notifications JFrame class.
My code for creating the notifications from my main JFrame
looks like this:
new Notification(from, msg, time);
I am wondering how i from within my notifications class can access my main JFrame
. Basically i want to change setVisible for some components on the main JFrame
from within my notifications class.
EDIT
My client.java (main JFrame
) calls the notification
public JPanel pnlMidMenuButtons;
/**** code... **/
Notification ntf = new Notification(from, msg, time); // Further down the notification is being called
ImportUI:
public class ImportUI extends Client implements NotificationParent {
public void setImportantFieldsVisible(boolean visible) {
pnlMidMenuButtons.setVisible(visible);
}
}
NotificationParent:
public interface NotificationParent {
public void setImportantFieldsVisible(boolean visible);
public void setAgentName(String agentName);
}
And my notification class:
public class Notification extends JFrame {
private NotificationParent parent;
/*...*/
public Notification(NotificationParent parent, String from, String msg, Date time) {
this.parent = parent;
parent.setImportantFieldsVisible(false); // Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
}
}
Any ideas whats causing the exception?