• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Poker game - actionPreformed / listener question.

 
Vinny sgarzi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I'm rather new to Java, and for my semester class's final we were told to really create anything of our choosing, and I chose to create a Poker Game.

Possibly not my best decision, seeing as poker gets quite complicated as you get down to the nitty grittys in the rules.

Anyways, I'm nearing completion (hopefully) but i still have a major major part of the game remaining, the betting.

I have created my window, and it's buttons and such, but I'm not sure how to make my methods in the Game class access the ActionListener in my Window class, so that when it is the user's turn, if they click on, say, the "bet" button, the bet will be read and added to the pool.

not sure how much of the code I should Include, but here is the Window Class



and here is (ideally) where the actionEvents will be "read?", in the Game class



There's much more to the code, obviously, and if seeing more would help understand my issue just let me know.

Thanks!
 
Carey Brown
Bartender
Posts: 2257
28
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinny sgarzi wrote:I have created my window, and it's buttons and such, but I'm not sure how to make my methods in the Game class access the ActionListener in my Window class, so that when it is the user's turn, if they click on, say, the "bet" button, the bet will be read and added to the pool.

I think it happens the other way around, the ActionListener should access your Game methods.
 
Vinny sgarzi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Vinny sgarzi wrote:I have created my window, and it's buttons and such, but I'm not sure how to make my methods in the Game class access the ActionListener in my Window class, so that when it is the user's turn, if they click on, say, the "bet" button, the bet will be read and added to the pool.

I think it happens the other way around, the ActionListener should access your Game methods.


That would make sense.. except then how do I make sure that it only does the action if it is that player's turn?
 
Carey Brown
Bartender
Posts: 2257
28
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinny sgarzi wrote:That would make sense.. except then how do I make sure that it only does the action if it is that player's turn?

Could the ActionListener call a isItMyTurn() method? Or could a game method() do the right thing knowing whose turn it is?
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you get the game working from the command line? You should have a game application and put a GUI atop it. The application should handle turns and rules. All you do with the GUI is add a display.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!