aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Enter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Enter method "paint" more than once?" Watch "Enter method "paint" more than once?" New topic
Author

Enter method "paint" more than once?

ajay smith
Greenhorn

Joined: Feb 02, 2013
Posts: 11
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

Joined: Oct 27, 2005
Posts: 19723
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Welcome to the Ranch
I shall move this discussion to our GUIs forum.
 
Don't get me started about those stupid light bulbs.
 
subject: Enter method "paint" more than once?