import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SquareAnon extends JFrame { private JButton button; private JTextField input; public SquareAnon() { super("Square GUI"); button = new JButton("Square"); input = new JTextField(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new GridLayout(1,2)); add(button); add(input); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int value; value= Integer.parseInt(input.getText()); input.setText(Integer.toString(value * value)); } }); pack(); setVisible(true); } public static void main(String[] args) { Square app; app = new Square(); } }