73c import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LabelText extends JFrame { public LabelText() { JLabel label1, label2; JTextField edit1, edit2; JButton button; label1 = new JLabel("Name: "); label2 = new JLabel("Address: "); edit1 = new JTextField(30); edit2 = new JTextField(10); //Layout the labels in a panel JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(0, 1, 0, 20)); labelPane.add(label1); labelPane.add(label2); //Layout the text fields in a panel JPanel fieldPane = new JPanel(); fieldPane.setLayout(new GridLayout(0, 1, 0, 20)); fieldPane.add(edit1); fieldPane.add(edit2); JPanel buttonPane = new JPanel(); JButton okButton = new JButton("OK"); JButton cancelButton = new JButton("Cancel"); buttonPane.add(okButton); buttonPane.add(cancelButton); //Put the panels in another panel, labels on left, //text fields on right JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(20, 20, 10, 10)); BorderLayout borderLayout = new BorderLayout(); borderLayout.setHgap(10); borderLayout.setVgap(50); contentPane.setLayout(borderLayout); contentPane.add(labelPane, BorderLayout.WEST); contentPane.add(fieldPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.SOUTH); getContentPane().add(contentPane, BorderLayout.CENTER); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); } public static void main(String args[]) { LabelText window = new LabelText(); window.setTitle("Labels And Text Fields"); window.pack(); window.setLocation(300, 250); window.setVisible(true); } } . 0