title: Action Listeners and inner classes java
body: <p>So I have a nested class in my public static void main. It seems to compile and be correct but the function it is supposed to perform doesn't seem to execute.  Here is the method.</p>
  
  <pre><code>public static void main(String[]args)
  {
  
    LevelOne l = new LevelOne();
    //Level Two not made yet just a place holder to show constructor with a different type
    LevelTwo l2 = new LevelTwo();
    //I make l2 first because the front frame is the last one created
    Main m = new Main(l2);
    Main m2 = new Main(l);
    //To switch levels i am going to load them all in advance and then when the beat the level it will close the frame
  
    class ChoiceListener implements ActionListener
    {
        Timer tm = new Timer(5, this);
        //timer is used for the actionlistener
        public void actionPerformed(ActionEvent e) 
     {
      if(l.checkWin())
     {
       m2.setVisible(false);
       m2.dispose();
      }
     }
  
      }
  
    }
  </code></pre>
  
  <p>And here is the variable it is supposed to access form level l in the other class.</p>
  
  <pre><code>public void setWin()
  {
     this.checkWin = true;  
  }
  
  public boolean checkWin()
  {
    return this.checkWin;  
  } 
  </code></pre>
  
  <p>checkWin is a private instance field for the other class. For some reason when checkWin is set to true it still wont execute. Any help would be appreciated!</p>