/* * A Java program that performs a simple layout. * It puts a growable text entry box with a button * on the top with a html box in the middle. * * Ben Bederson, March 18, 2002 */ import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; public class SimpleLayout extends JFrame { JPanel panel; JTextField textField; JButton goButton; JEditorPane editorPane; static public void main(String[] args) { new SimpleLayout(); } public SimpleLayout() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel = new JPanel(); panel.setBackground(Color.pink); panel.setPreferredSize(new Dimension(400, 400)); createInterface(); getContentPane().add(panel); pack(); setVisible(true); } void createInterface() { textField = new JTextField(); goButton = new JButton("Go"); editorPane = new JEditorPane(); JPanel northPane = new JPanel(); northPane.setLayout(new BorderLayout()); northPane.add(textField, BorderLayout.CENTER); northPane.add(goButton, BorderLayout.EAST); panel.setLayout(new BorderLayout()); panel.add(northPane, BorderLayout.NORTH); panel.add(new JScrollPane(editorPane), BorderLayout.CENTER); } }