This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Pick four cards (GUI) Problems  RSS feed

 
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
Bartender
Posts: 3210
78
  • 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
Bartender
Posts: 3210
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!