title: How Do I Get Input From A JTextField, Then Store It In A Variable?
body: <p>I've setup a JTextField, for users to input the base of the triange (It's a triangle area calculator) and I need to know how to store their input into a variable.</p>
  
  <p>I tried an action listener but it game an error.</p>
  
  <pre><code>import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.Scanner;
  
  import javax.swing.*;
  
  public class Triangle extends JFrame implements ActionListener{
  
  static Scanner sc = new Scanner(System.in);
  
  public static void findingTriangle(){
  
      JFrame jf = new JFrame();
      JTextField textfield = new JTextField("", 30);
      JPanel panel = new JPanel();
      JLabel jl = new JLabel("Triangle Area Calculator");
      jf.setSize(500, 500);
      jf.setVisible(true);
      jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      jf.add(panel);
      panel.add(jl);
      panel.add(textfield);
      }
  
      public static void main(String[] args){
  
          findingTriangle();
  
      }
  
      @Override
      public void actionPerformed(ActionEvent arg0) {
          // TODO Auto-generated method stub
  
      }
  }
  </code></pre>