title: Changing variables across methods
body: <p>I have my GUI set up so that if the button <code>b1</code> is pressed: </p>
  
  <pre><code> public class CubeCalc  {
  
   static int next = 0;
  
   public static void MakeTitlePage()
   {
    final JFrame window = new JFrame("Cubic Feet Calculator"); //Creates Frame
  
    JButton b1 = new JButton("Start");
    b1.setBackground(Color.decode("#5A20DF"));
       b1.setForeground(Color.WHITE);
       /*b1.setLayout(new GridBagLayout());*/
       b1.setPreferredSize(new Dimension(150,50));
    b1.addActionListener(new ActionListener() { // action when button is pressed
              int pressCount=0;
              @Override
              public void actionPerformed(ActionEvent e) {
  
                  window.dispose();
                 next = 1;
  
  
              }
          });
  </code></pre>
  
  <p>then it will dispose of the title page and and <code>next</code> will equal one, and on the Event Dispatch Thread, it creates a new page that does other things: </p>
  
  <pre><code>public static void main(String[] args) {
  
          SwingUtilities.invokeLater(new Runnable() { // launch frame on the Event Dispatch Thread
              @Override
              public void run() {
                   MakeTitlePage();
  
                   if (next==1)
                   {
                     MakeCalcPage();
                   }
  
                   System.out.println(next);
              }
          });
   }
  </code></pre>
  
  <p>The problem is that the variable <code>next</code> remains equal to zero even though I have changed it in the method <code>MakeTitlePage()</code>. How do I change the variable across <em>all</em> the methods, and not just that one?</p>