title: Acces variables from an inner class in java
body: <p>I need to modify a variable from an inner class. The compiler says I need to declare the variable static, but then I can't modify it. The code is something like this:</p>
  
  <pre><code>public class Outter{
     private boolean b;
  
     public Outter(){  
        b = false;
        new Inner(b);
     }
  }
  
  public class Inner{
     public Inner(boolean b){
        b = true;
     }
  }
  </code></pre>
  
  <p>Is there anything like the "extern" in C? Or any solution so I could modify the b variable? I've tried setting it to static and passing the whole Outter class as a parameter, but I keep having the same problem.</p>
  
  <p>EDIT:
  Well the code is more like:</p>
  
  <pre><code>public class MainView{
     private boolean view;
     //JMenus,JMenuItems, JPanels.. declarations
     private JFrame frame
     MainView(){
       view = true;
       //initializations
       create_listeners();
     }
     public void create_listeners(){
        Menu.addActionListener(
          new ActionListener() { 
              public void actionPerformed(ActionEvent event){
                  if(View){
                      new View2(frame);
                      View = false;
                  }
              }
  
          }  
     );
     }
  }
  
  public class View2{
     private JButton back = new JButton("Back");
     public View2(JFrame frame){
      //initialitzatons
      create_listeners();
  }
     public void create_listeners(){
            back.addActionListener(
          new ActionListener() { 
              public void actionPerformed(ActionEvent event){
                  frame.remove(MainPanel);
                  View = true;// HERE, i want to modify the variable
                  }
  
          }  
      );
      }
   }
  </code></pre>
  
  <p>The problem is how should I modify the variable "View" from the View2 class. </p>
  
  <p>Sorry for bad tabulation, I did it quick and required code translation to be understood.</p>