title: How to get value from constantly changing variable
body: <p>I'm creating some kind of menu (in swing), here's my code</p>
  
  <pre><code>public class JavaApplication5
  {
      public static void main(String[] args) 
      {       
          NewJFrame frame = new NewJFrame();
          frame.setVisible(true);
  
          if(frame.getRunning() == true)
          {
             System.out.println("why it doesn't work");
          }
      }
  }
  </code></pre>
  
  <p>And here is my menu class:</p>
  
  <pre><code>public class NewJFrame extends javax.swing.JFrame 
  {
      public boolean isRunning = false;
  
      public void setRunning(boolean isRunning)
      {
          this.isRunning = isRunning;
      }
  
      public boolean getRunning()
      {
          return isRunning;
      }
  
      public NewJFrame() 
      {
          initComponents(); //this refers to auto-generated code by swing library
      }
      //some swing stuff...
  
      private void PlayActionPerformed(java.awt.event.ActionEvent evt) {                                     
          this.setRunning(true);
          System.out.println(getRunning());
      }
  }
  </code></pre>
  
  <p>And the output is whenever i click on "Play" button:
  "true
  true
  true"</p>
  
  <p>And here my question rises: Why in the output's console, the following line is not displayed "why it doesn't work" if I've changed that value from false to true (by pressing button)? How to call that constanly changing variable in the main function? Thanks in advance.</p>