// SimpleGUI1.java
// Simple GUI with a text field and a text area
// Program doesn't quit when window closes.
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* Displays window with a text area and a text field,
* both of which the user can type on and edit.
*
* @author D. Nixon
*/
public class SimpleGUI1 {
/**
* Main method
*
* @param args command-line arguments - none needed
*/
public static void main(String[] args)
{
// Create window object (but it won't be visible yet):
JFrame window = new JFrame();
// Set size of window in pixels:
window.setSize(400, 250);
// Set window's distance, in pixels, from
// left and top of screen:
window.setLocation(100, 100);
// Set text displayed by window's title bar:
window.setTitle("Simple GUI example");
// Prepare to add text area and text field:
Container contentPane = window.getContentPane();
// Create and add text area in center:
JTextArea bigTextArea = new JTextArea();
bigTextArea.setEditable(true);
bigTextArea.setText("You can type text here.");
contentPane.add(bigTextArea, BorderLayout.CENTER);
// Create and add text field at bottom:
JTextField bottomField = new JTextField();
bottomField.setEditable(true);
bottomField.setText("You can type text here too.");
contentPane.add(bottomField, BorderLayout.SOUTH);
// Make window appear on the screen:
window.setVisible(true);
// The window will now remain visible and continue
// running until the user closes it.
} // method main
} // class SimpleGUI1