• 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

Empty JPanel's aren't invisible

 
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've been trying to get JTextFields onto my JFrame using the GridBagLayout. I've managed to do this. I was recommended to use empty JPanels with weightx / weighty set as 1, in order to space things out like I wanted. This seemed to work until I put a jpg image onto my frame, and I noticed 2 small grey(same colour as regular background) squares in the centres of the regions where I placed the 2 empty JPanels.

Is there anyway of getting rid of these squares, or doing it some other way??
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Uh, I think that wasn't a good recommendation. Can you tell us more about your current layout, so that we can find a better solution? Show some code perhaps?
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to keep your solution, you should probably call setOpaque on the panels, by the way...
 
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
Its ok, I've read a bit further into my book and have been able to use anchors to position my components, without the need for empty JPanels.
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic