import java.awt.*;
import javax.swing.*;

public class JTextExample extends JFrame {

	public JTextExample() {
		super("JText example");
		Container cp = getContentPane();

		JTextField tf = new JTextField(20);
		JTextArea ta = new JTextArea(5, 20);
		JScrollPane sp =
			new JScrollPane(
				ta,
				JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS));
		cp.add(Box.createRigidArea(new Dimension(150, 10)));
		cp.add(tf);
		cp.add(Box.createRigidArea(new Dimension(150, 10)));
		cp.add(sp);
		cp.add(Box.createRigidArea(new Dimension(150, 10)));
	}

	public static void main(String args[]) {
		JTextExample b = new JTextExample();
		b.pack();
		b.setVisible(true);
	}
}
