title: How can I pull variables out of a Static class?
body: <p>As the title says I would like to pull some variables out of different classes. In class I was tasked with producing a magic square which isn't particularly hard to code so I thought I would make an interactive GUI for and because I had never coded with GUI before I had to learn how to use JLabel and JButton etc.</p>
  
  <p>I believe I am successful with such learning this on my own being able to come up with a dialog box with the different sections which opens a prompt menu however I have added a confirm button which I would like to show what the user has entered. I have used JOptionPane.showMessageDialog to get user input and assigned it to a variable however I have no idea how to pull the variable out of it's class into the main where I can use it for other purposes. I have tried using this: classname.membername however I can't get it to work.</p>
  
  <p>Code Below:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.awt.event.*;
  import javax.*;
  
  public class Magic_SquareR {
  
      static boolean confirm = false;
  
      public Magic_SquareR() {
          gui();
      }
  
          public void gui() {
  
  
          JFrame f = new JFrame();
  
          f.setVisible(true);
          f.setSize(350, 150);
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.setLayout(new FlowLayout());
  
          JPanel p = new JPanel(new GridBagLayout());
  
          JButton b1 = new JButton("ML");
          JButton b2 = new JButton("TL");
          JButton b3 = new JButton ("BL");
          JButton b4 = new JButton ("TM");
          JButton b5 = new JButton ("MM");
          JButton b6 = new JButton ("BM");
          JButton b7 = new JButton ("TR");
          JButton b8 = new JButton ("MR");
          JButton b9 = new JButton ("BR");
          JButton b10 = new JButton ("Confirm");
  
  
  
  
  
          GridBagConstraints c = new GridBagConstraints();
  
          c.insets = new Insets(5,5,5,5);
          c.gridx = 0;
          c.gridy = 0;
  
          p.add(b2,c);
          b2.addActionListener(new Action());
  
          c.gridx = 0;
          c.gridy = 100;
          p.add(b1,c);
          b1.addActionListener(new Action2());
  
  
          c.gridx = 0;
          c.gridy = -100;
          p.add(b3,c);
          b3.addActionListener(new Action3());
  
          c.gridx = 100;
          c.gridy = 000;
          p.add(b4,c);
          b4.addActionListener(new Action4());
  
          c.gridx = 100;
          c.gridy = -100;
          p.add(b5,c);
          b5.addActionListener(new Action5());
  
          c.gridx = 100;
          c.gridy = -100;
          p.add(b6,c);
          b6.addActionListener(new Action6());
  
  
          c.gridx = -100;
          c.gridy = -100;
          p.add(b7,c);
          b7.addActionListener(new Action7());
  
          c.gridx = 200;
          c.gridy = -100;
          p.add(b8,c);
          b8.addActionListener(new Action8());
  
          c.gridx = 200;
          c.gridy = -100;
          p.add(b9,c);
          b9.addActionListener(new Action9());
  
  
          c.gridx = 100;
          c.gridy = 300;
          p.add(b10,c);
          b10.addActionListener(new Action10());
  
          f.add(p);
  
      }
  
  
  static class Action implements ActionListener {
  
          public void actionPerformed (ActionEvent e) {
  
              String TL = JOptionPane.showInputDialog("Please enter a number from 1-10 for TL");
              int tl = Integer.parseInt(TL);
  
  
          }
      }
  
  static class Action2 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String ML = JOptionPane.showInputDialog("Please enter a number from 1-10 for ML");
          int ml = Integer.parseInt(ML);
  
      }
  }
  
  static class Action3 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String BL = JOptionPane.showInputDialog("Please enter a number from 1-10 for BL");
          int bl = Integer.parseInt(BL);
  
      }
  }
  
  static class Action4 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String TM = JOptionPane.showInputDialog("Please enter a number from 1-10 for TM");
          int tm = Integer.parseInt(TM);
  
  
      }
  }
  
  static class Action5 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String MM = JOptionPane.showInputDialog("Please enter a number from 1-10 for MM");
          int mm = Integer.parseInt(MM);
  
  
      }
  }
  
  static class Action6 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String BM = JOptionPane.showInputDialog("Please enter a number from 1-10 for BM");
          int bm = Integer.parseInt(BM);
  
  
      }
  }
  
  static class Action7 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String TR = JOptionPane.showInputDialog("Please enter a number from 1-10 for TR");
          int tr = Integer.parseInt(TR);
  
  
      }
  }
  
  static class Action8 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String MR = JOptionPane.showInputDialog("Please enter a number from 1-10 for MR");
          int mr = Integer.parseInt(MR);
  
  
      }
  }
  
  public class Action9 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          String BR = JOptionPane.showInputDialog("Please enter a number from 1-10 for BR");
          int br = Integer.parseInt(BR);
  
  
      }
  
  
  }
  
  public class Action10 implements ActionListener {
  
      public void actionPerformed (ActionEvent e) {
  
          JOptionPane.showMessageDialog(null, "Welcome to the end - This is where we check your answers");
          JOptionPane.showMessageDialog(null, "For BR your wrote " + Action9.BR);
  
  
  
      }
  
  
  }
  
      public static void main(String args[]) {
  
  
  
          new Magic_SquareR();
  
  
  
          {
  
  
  
  
  }
  </code></pre>