cannot find symbol for button
posted 1 year ago
I would suggest the real problem is incorrect use of the ActionListener interface. One of at least three design problems I can see.
1: Don't use AWT, which was superseded by Swing over 15 years ago. Since Swing is probably on it way out, maybe you should use JavaFX instead of Swing. 2: You are extending display classes, which is probably a bad idea. You can add Components to a frame easily without subclassing the frame (see below). 3: You are making the display class implement ActionListener which is an abomination against object‑oriented programming, even though you will see it in the books. Use a separate class which implements ActionListener, whether public private or anonymous. In Java8 you would use a λ rather than an anonymous class. That way there will be no actionPerformed method in the display class, and no need for == btn1 and the compiler error will disappear.