• Post Reply Bookmark Topic Watch Topic
  • New Topic

Empty JPanel's aren't invisible

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • 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??
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!