title: How to get data from a textfield in java and display it into a jlabel on the second form
body: <p>I was trying to build a simple java GUI application to get the data from the user and display it to the label.</p>
  
  <p>I got this code from the internet but it is using a separate pane for displaying the result.</p>
  
  <pre><code>     import javax.swing.*;
       import java.awt.*;
       import java.awt.event.*;
       public class JTextFieldDemo extends JFrame {
  
  //Class Declarations
  JTextField jtfText1, jtfUneditableText;
  String disp = "";
  TextHandler handler = null;
  //Constructor
  public JTextFieldDemo() {
      super("TextField Test Demo");
      Container container = getContentPane();
      container.setLayout(new FlowLayout());
      jtfText1 = new JTextField(10);
      jtfUneditableText = new JTextField("Uneditable text field", 20);
      jtfUneditableText.setEditable(false);
      container.add(jtfText1);
      container.add(jtfUneditableText);
      handler = new TextHandler();
      jtfText1.addActionListener(handler);
      jtfUneditableText.addActionListener(handler);
      setSize(325, 100);
      setVisible(true);
  }
  //Inner Class TextHandler
  private class TextHandler implements ActionListener {
  
              @Override
      public void actionPerformed(ActionEvent e) {
          if (e.getSource() == jtfText1) {
              disp = "text1 : " + e.getActionCommand();
          } else if (e.getSource() == jtfUneditableText) {
              disp = "text3 : " + e.getActionCommand();
          }
          JOptionPane.showMessageDialog(null, disp);
      }
  }
  //Main Program that starts Execution
  public static void main(String args[]) {
      JTextFieldDemo test = new JTextFieldDemo();
      test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  </code></pre>