Hey, just have a quick question. I'm creating a GUI for a program which does different calculations based on what button you press and it's my first time using ActionListeners. I'm wondering, do I have to create a new class implementing ActionListener for every individual button or is there a different way of coding them. For example, below is the part of my code where I have my action listeners and it just seems a bit tedious to have to keep implementing that class, especially when some of the actions are very similar. Many thanks in advance for any help given.
class BasicListener implements ActionListener { // Calculate basic pay public void actionPerformed(ActionEvent e) { String bPay = _basicHours.getText(); bAmount = Double.parseDouble(bPay) * BASIC_PAY; _basicTotal.setText(""+bAmount); } } class HolsListener implements ActionListener { // Calculate holiday pay public void actionPerformed(ActionEvent e) { String hPay = _holsHours.getText(); hAmount = Double.parseDouble(hPay) * HOLS_PAY; _holsTotal.setText(""+hAmount); } } class TotalListener implements ActionListener { // Calculate final earnings public void actionPerformed(ActionEvent e) { finalAmount = bAmount+hAmount; _finalAmount.setText("" + finalAmount); } }