title: I want to use a variable outside of "public void actionPerformed(ActionEvent e) {}"
body: <p>I need to create a GUI and enter the height and width there, click on the button and a new window will start with these heights and widths. Аt the moment I have variable values width and height  ​​which are set in public void actionPerformed(ActionEvent e) {} and I want to use them to transfer the values ​​for a new window. I came to the conclusion that it is necessary either to pull values ​​from the JTextField itself or the way that I want to implement</p>
  
  <pre><code>public class Form extends JFrame implements Runnable {
      //private int w= 1280;
      //private int h=768;
      public int wt;
      public int ht;
      public void Okno() {
  
          JFrame win1 = new JFrame("Evolution.IO");       
          win1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          win1.setLayout(new BorderLayout());
          win1.setSize(470, 400);
  
          JPanel pane = new JPanel();
          pane.setLayout(new FlowLayout());
          JTextField txtField = new JTextField(5);
          JTextField txtField2 = new JTextField(5);
          JLabel weightL = new JLabel("Weight: ");
          JLabel highL = new JLabel("High: ");
          pane.add(weightL);
          pane.add(txtField);
          pane.add(highL);
          pane.add(txtField2);
  
          JButton btn = new JButton("Начать симуляцию");
          btn.addActionListener(new ActionListener() {
  
  
              @Override
              public void actionPerformed(ActionEvent e) {
  
                  wt = Integer.parseInt(txtField.getText());
                  ht = Integer.parseInt(txtField2.getText());
                  if (!(txtField==null)) {
                      Form f = new Form();
                      new Thread(f).start();
                      win1.getDefaultCloseOperation();
                  }
              }
          });
          pane.add(btn);
          win1.add(pane);
          win1.setLocationRelativeTo(null);
          win1.setVisible(true);
      }
      //THIS DOESNT WORK#
  //  public int w1() {
  //        return this.wt;
  //     }
  //  public int h1() {
  //        return this.ht;
  //     }
  
      private final int FRAMES_TOTAL = 100000;
      private final int SKIP_FRAMES = 10;
  
      private final Color BG = new Color(200, 200, 200, 255);
      private final Color BLUE = new Color(150, 160, 255, 255);
      private final Color RED = new Color(255, 100, 120, 255);
      private BufferedImage buf = new BufferedImage(w1(), h1(), BufferedImage.TYPE_INT_RGB);
      private BufferedImage img = new BufferedImage(w1(), h1(), BufferedImage.TYPE_INT_RGB);
      private BufferedImage graph = new BufferedImage(w1(), h1(), BufferedImage.TYPE_INT_ARGB);
  //no longer needed
  </code></pre>