This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring 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: 20492
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
Posts: 48363
56
  • 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