How should I access frame buttons from a controller in an MVC approach?
Posted
by
Loris
on Game Development
See other posts from Game Development
or by Loris
Published on 2014-06-05T17:24:01Z
Indexed on
2014/06/05
21:43 UTC
Read the original article
Hit count: 239
I'm developing an italian card game using the mvc pattern. I have the class GameFrame that contains the view. The user's card are buttons (JButton objects). I have 3 controllers:
- GameController: to control the game in general. Contains the game loop.
- HumanPlayerController: to control the user input
- ComputerPlayerController: contains the AI of the computer
- PlayerController: is an interface with the makeTurn() method. It's implemented by HumanP.C. and ComputerP.C.
HumanPlayerController implements ActionListener too. But what is the right way to access to the GameFrame buttons? I need it for understand which card was chosen.
GameFrame and HumanPlayerController are in different packages. Should i make the JButtons public?
© Game Development or respective owner