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 okButton.addActionListener(this); // 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 void actionPerformed(ActionEvent e) { // evaluate the expression ExpressionParser.test(text.getText()); } public static void main(String[] args) { CalculatorMain myCalc = new CalculatorMain(); }}// ------------------------------------------------------------public class ExpressionParser{ public static void test(String text) { // put something in the textfield to show we have access to it }}