I'm trying to figure out how I can have a class listen to another. So this is the idea.
I have a MainFrame
class, which is simply a container class, JFrame container, that takes an argument of type JPanel. Basically I want this container class to be able to switch between frames depending on what my other class, FrameSwitcher
, will tell it to do.
The other classes are: FrameSwitcher, MainMenu and ScoreBoards
.
The idea is that, let's say MainMenu
, will contain 4 buttons, each one will listen, BUT will NOT change the frames. Rather it will somehow - and this is the part I need help with - send to the FrameSwitcher
what button was clicked, and this information will then be sent to MainFrame
to switch to the appropriate frames.