• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Enter method "paint" more than once?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 22446
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 73984
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
I shall move this discussion to our GUIs forum.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic