title: How to get text from a JTextfield and use it as an int
body: <p>I have all of this in one file.  I am trying to get the int from the text field jtfNumber1 and jtfNumber2 and then display the result of the action based on which button is pressed into into jtfResult.  I have the buttons working.  They currently display a test message.  I am stuck with getting the string from the textfield.  </p>
  
  <pre><code>public class Calculator extends JFrame {
  
      // Create Buttons and fields
      private JButton jbtAdd = new JButton("Add");
      private JButton jbtSub = new JButton("Subtract");
      private JButton jbtMul = new JButton("Multiply");
      private JButton jbtDiv = new JButton("Divide");
      private JTextField jtfNumber1 = new JTextField(8);
      private JTextField jtfNumber2 = new JTextField(8);
      private JTextField jtfResponse = new JTextField(8);
  
      public Calculator() {
          //Create Panel
          JPanel panel = new JPanel();
          panel.add(new JLabel("Number 1"));
          panel.add(jtfNumber1);
          panel.add(new JLabel("Number 2"));
          panel.add(jtfNumber2);
          panel.add(new JLabel("Result"));
          panel.add(jtfResponse);
          panel.add(jbtAdd);
          panel.add(jbtSub);
          panel.add(jbtMul);
          panel.add(jbtDiv);
          add(panel);
          BtnListener listener = new BtnListener();
          jbtAdd.addActionListener(listener);
          jbtSub.addActionListener(listener);
          jbtMul.addActionListener(listener);
          jbtDiv.addActionListener(listener);
      }
  
      class JtfListener implements ActionListener {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              int x = Intenger.parseInt(jtfNumber1.getText());
          }
      }
  
      class BtnListener implements ActionListener {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              if (e.getSource() == jbtAdd) {
                  System.out.println("Test Test Test");
              } else if (e.getSource() == jbtSub) {
                  System.out.println("Test Test Test");
              } else if (e.getSource() == jbtMul) {
                  System.out.println("Test Test Test");
              } else if (e.getSource() == jbtDiv) {
                  System.out.println("Test Test Test");
              }
          }
      }
  
      public static void main(String[] args) {
          JFrame frame = new Calculator();
          frame.setTitle("Calculator");
          frame.setLocationRelativeTo(null);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.setVisible(true);
      }
  }
  </code></pre>