• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help w/ displaying several .PNG files

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am very new to Java, and I am trying to make a graphical Craps game. If you're familiar with Craps, then you know that there are about 40 different bets meaning there are 40 different places to put poker chips on the table. I'd like to show a poker chip on every bet location on the table where the player has actually placed a bet.

The best approach I can come up with so far is to:
1. Make 40 extended JPanel inner classes (inner to the actual extended JFrame class)
2. Override the paintComponent() method for each panel
3. Use the drawImage() method to paint the picture on the panel
4. Add every panel to the frame.

Then, as the user wins, loses, or places bets, I can turn the visibility off or on for the panels as needed.

The only other approach I can think of is constructing and destroying the panels as needed for each chip shown. I'm hoping there's a way to just say "if... show x picture at this location" and "if... remove x picture".

Am I way off track here? Is there a better way? Please help.

Thanks in advance.
Tom
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Pete. You may have missed our naming policy when you registered, but we ask that people use a display name that is a first name and last name and not obviously fake. You can change your name here.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
reply
    Bookmark Topic Watch Topic
  • New Topic