import java.awt.*; // older GUI library, has layout stuff for components import java.awt.event.*; // events import javax.swing.*; // swing is a library of GUI components // example GUI with text fields // class extends JFrame, so it is its own window public class MakeText extends JFrame{ private JTextField textboxin; private JTextField textboxout; // constructor does all setup of window and buttons public MakeText() { // call the JFrame constructor super("I'll Quote You"); // using methods inherited from JFrame // close the program if we close the window setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // put new added widgets in from left to right setLayout(new FlowLayout()); // input text box textboxin = new JTextField(10);// how many characters textboxin.addActionListener( // the anonymous inner class to respond to enter from the text box new ActionListener() { // implementing this interface public void actionPerformed(ActionEvent e) { textboxout.setText("You said \"" + textboxin.getText() + "\""); } } ); // output text box -- don't allow user to change text textboxout = new JTextField(20);// how many characters textboxout.setEditable(false); // put the widgets in the window add(textboxin); add(textboxout); // size based on widgets pack(); // make the window visible setVisible(true); } // main to launch the GUI public static void main(String[] args) { MakeText makeTextEx = new MakeText(); } }