public class tCalculator implements ActionListener{ //private JTextField resultText; public void Calculator(){ btn1.addActionListener(this); btn2
public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); if (source instanceof JButton){ JButton but = (JButton) source; String text = but.getText(); //do what you want with the text } }}