This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 9
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: 19654
    
  18

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: 38025
    
  22
Welcome to the Ranch
I shall move this discussion to our GUIs forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enter method "paint" more than once?
 
Similar Threads
Using arrays to randomly generate images? (applet)
Logging problem and grammatical problems
card game
reading a private method within a class
Start: Applet not initialized