I need to know how to save input as a variable for later use.

Here is the code so far:

 

import java.awt.event.*;

import javax.swing.*;

import java.awt.*;

 

public class TextGUI extends JFrame{

    

     public TextGUI(){

          super("Text Test");

          setLayout(new FlowLayout());

              

          JTextField test = new JTextField("Enter text", 30);

          add(test);

         

          JButton OK = new JButton("OK");

          add(OK);

         

          HandlerClass handler = new HandlerClass();

          OK.addActionListener(handler);

         

               }

    

     private class HandlerClass implements ActionListener{

          public void actionPerformed(ActionEvent event){

          }

     }

}

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners