• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Modifying a GridLayout/Changing Labels

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
here's a simple demo

 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!