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(myCalc.text.blah!!!!); // 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 expression) { // put something in the textfield to show we have access to it } }