import javax.swing.*;import java.awt.*;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;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(this.text.getText()); // this is where it goes tits up } public static void main(String[] args) { CalculatorMain myCalc = new CalculatorMain(); }}// ------------------------------// Other Class File:public class ExpressionParser{ public static void test(String textFieldContents) { String expression = textFieldContents; // do something wild and fun :) }}