• 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

Modifying a GridLayout/Changing Labels

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm making a program that uses a 10 X 10 GridLayout in which each position on the grid is a certain JLabel with an image icon in it. I have made a command so that when you type a letter, it loads up a different image, and then, upon clicking on a certain position on your Grid, it will remove that JLabel and place the one you have there. I tried doing this simply by replacing the JLabel at that position but it didn't modify anything. So then, I removed the JLabel at that position from my JPanel itself and then want to add the new JLabel in it's place at that position. However, the GridLayout takes my newly added JLabel and plops it down at the bottom.
Is there anyway I can add a JLabel to my GridLayout at my desired position? Or, if that's not possible, how do i change a JLabel from one image to another without removing it and adding it to the program again?
Thanks, I'll offer more info as is needed.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here's a simple demo

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic