import javax.swing.*; import java.awt.event.*; class Five extends JFrame implements ActionListener { JButton submitButton = new JButton("Click me!"); JLabel nameLabel = new JLabel("Name: "); JTextField nameField = new JTextField(10); Five(String title, int width, int height) { JPanel panel = new JPanel(); panel.add(nameLabel); panel.add(nameField); panel.add(submitButton); this.add(panel); submitButton.addActionListener( this ); this.setSize(width, height); this.setTitle(title); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } public static void main(String[] args) { Five f = new Five("Simple Frame", 300, 100); } public void actionPerformed(ActionEvent e) { System.out.println("Well, hello there, " + this.nameField.getText()); } }