title: Java setVisible from one JFrame class to another?
body: <p>I've got a main <code>JFrame</code> that creates an instance of a basic notifications JFrame class.</p>
  
  <p>My code for creating the notifications from my main <code>JFrame</code> looks like this:</p>
  
  <pre><code>new Notification(from, msg, time);
  </code></pre>
  
  <p>I am wondering how i from within my notifications class can access my main <code>JFrame</code>. Basically i want to change setVisible for some components on the main <code>JFrame</code> from within my notifications class.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My client.java (main <code>JFrame</code>) calls the notification</p>
  
  <pre><code>public JPanel pnlMidMenuButtons;
  /**** code... **/
  Notification ntf = new Notification(from, msg, time); // Further down the notification is being called
  </code></pre>
  
  <p>ImportUI:</p>
  
  <p>public class ImportUI extends Client implements NotificationParent {</p>
  
  <pre><code>public void setImportantFieldsVisible(boolean visible) {
      pnlMidMenuButtons.setVisible(visible);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>NotificationParent:</p>
  
  <pre><code>public interface NotificationParent {
      public void setImportantFieldsVisible(boolean visible);
      public void setAgentName(String agentName);
  }
  </code></pre>
  
  <p>And my notification class:</p>
  
  <pre><code>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 
      }
  
  }
  </code></pre>
  
  <p>Any ideas whats causing the exception?</p>