title: Disposing JFrame from another class
body: <p>How can I dispose <code>JFrame</code> from another class? My code is listed below.</p>
  
  <pre><code>public class MainWindow
  
  {
  
  JFrame main_f = new JFrame("xx");
  main_f.getContentPane().setLayout(new BorderLayout());
  main_f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  .
  .
  .
  }
  </code></pre>
  
  <p>Disposing class:</p>
  
  <pre><code>public static void DisposingJFrame (){
  .
  .
  .
  MainWindow.main_f.dispose();
  }
  </code></pre>
  
  <p><code>MainWindow.main_f.dispose()</code> won't work because <code>main_f</code> isn't a variable. Can you help me?</p>