• 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

chess pieces

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have built a chess game, and I've got a GUI up and running,
but at the moment, I'm just using Strings for the pieces.
eg "q" for white queen, "Q" for black queen.
Does anyone know how to get jpg images inside a Java Frame.
Or failing that, I cud try drawing sum pieces.
Any ideas?

Thanks
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



you'v to have in mind that every piece has to have two diferent (white and black) backgrounds
[ May 29, 2005: Message edited by: miguel lisboa ]
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Thanks very much. I've copied and pasted the code. I'm
pretty sure you need your import statements at the top. Anyway,
it works with these at the top, but I just have an empty frame.
Im not sure how the following bit works exactly:

Image imagem = new ImageIcon("a.jpg").getImage();

Where do I need to have the jpg image stored?
Is it in the same folder as the code?
I'm just gonna try it and see
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha, I was right, I got a picture in the frame now, any Idea how to adjust the size, or is it better to do this outside of the program, and then just use a smaller picture?
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
maybe there's a better/simpler way of doing it, but i'd do the following:

imagine each square has 75x75 px
then each panel (for each pic/square) will size that too

then the problem will be in the layout so as to put 8 squares per row
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic