public class CalculatorMain extends JFrame implements ActionListener{ public CalculatorMain() { // just a dialog box with a text field. and ok button JFrame expressionFrame = new JFrame("Expression Evaluator"); JTextField text = new JTextField(""); JButton okButton = new JButton("OK"); // add action listener and even handling code okButton.addActionListener(this); public void actionPerformed(ActionEvent e) { // evaluate the expression } // setup close operation on frame and the layouts expressionFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); expressionFrame.getContentPane().setLayout(new BorderLayout()); expressionFrame.getContentPane().add(text, BorderLayout.NORTH); expressionFrame.getContentPane().add(okButton, BorderLayout.SOUTH); // show the GUI expressionFrame.pack(); expressionFrame.show(); } public static void main(String[] args) { new CalculatorMain(); }}