i just learned GUI applications in my class but im getting an error i dont know why
package Chapter7; import javax.swing.*; import java.awt.event.*; import java.awt.*; public class RetalPrice extends JFrame { int itemCost; double markupPercentage; JTextField answer; JTextField answer2; JButton button; public RetalPrice() { int width = 400; int length = 150; setTitle("Retail Price Calculator"); setSize(width,length); JLabel question = new JLabel("What is the item's cost"); JLabel question2 = new JLabel("what is the mark up percentage"); answer = new JTextField(10); answer2 = new JTextField(10); button = new JButton("calculate"); button.addActionListener(new CalcButtonListener()); //Line where im getting the error JPanel panel = new JPanel(); panel.add(question); panel.add(answer); panel.add(question2); panel.add(answer2); panel.add(button); add(panel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } private class CalcButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { int price; int tax; double finalPrice; String input; price = Integer.parseInt(answer.getText()); tax = Integer.parseInt(answer2.getText()); finalPrice = price + price * (tax/100); JOptionPane.showMessageDialog(null, "the final price is " + finalPrice); } } public static void main (String[]args) { RetalPrice tax = new RetalPrice(); } }
the error says The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguement RetalPrice.CalcButtonListener)
thank you in advance