// SimpleGUI3.java
// Simple GUI with a text field and a text area
// Subclass of JFrame
import java.awt.BorderLayout;
import java.awt.Container;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* Window with a text area and a text field,
* both of which the user can type on and edit.
*
* @author D. Nixon
*/
public class SimpleGUI3 extends JFrame
{
/**
* Creates this window.
*/
public SimpleGUI3()
{
// Size of this window in pixels:
setSize(400, 250);
// Set this window's distance, in pixels, from
// left and top of screen:
setLocation(100, 100);
// Set text displayed by title bar:
setTitle("Simple GUI example");
// Prepare to add text area and text field:
Container contentPane = 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);
// Enable program to quit when window closes:
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Make this window appear on the screen:
setVisible(true);
} // constructor
/**
* Main method
*
* @param args command-line arguments - none needed
*/
public static void main(String[] args)
{
new SimpleGUI3();
} // method main
} // class SimpleGUI3