Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enter method "paint" more than once?

 
ajay smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building a program to initialize a deck of cards, shuffle them (I use a Math.random) and display the
first ten cards of the deck in two rows of five. I have the logic figured out, but I'm running into two main
issues. One: how can i display the cards in two rows of five and two: why when I run my program does
the paint method be invoked multiple times?

Here is the code I have written:



any ideas?
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ajay smith wrote:One: how can i display the cards in two rows of five

A GridLayout comes to mind. You can use Labels for that. Or even better - use JApplet and JLabel instead. You shouldn't use AWT components anymore these days. It has been superseded by Swing ages ago.

and two: why when I run my program does the paint method be invoked multiple times?

Definitely. It's called many, many times during the lifetime of any application.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48950
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
I shall move this discussion to our GUIs forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic