• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pick four cards (GUI) Problems

 
gabriel terry
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Pick four cards) Write a program that lets the user click the Refresh button to display
four cards from a deck of 52 cards, as shown in Figure 16.21a. (Hint: See
Listing 6.2 on how to draw four cards randomly.)


I have a problem.The "refresh" button does nothing.Any ideea?



 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After changing components you need to revalidate() the panel and call redraw().

BTW your random mechanism is flawed as you can get the same cards drawn multiple times in one hand which is illegal. Once you shuffle a pack it is randomised so you can just take any 4 consecutive cards you don;t need to shuffle again after every card is taken.
 
gabriel terry
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's working! Thank you!
 
Tony Docherty
Saloon Keeper
Posts: 3138
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!