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: 236

Filed under:
|

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:

  1. GameController: to control the game in general. Contains the game loop.
  2. HumanPlayerController: to control the user input
  3. ComputerPlayerController: contains the AI of the computer
  4. 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

Related posts about java

Related posts about card-game