Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about JPanel  RSS feed

 
Alex Graham
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just wondering why this code will not show the label and button in the panel. I tried to shorted the code as much as possible. Thanks for any help.

 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You forgot to add the panel to the JFrame! Hence when visible it's blank.
 
Alex Graham
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to help out anyone that might need this. After some researching I found out all I had to do was add this:
and then it worked. I added it right before Thanks for the help.
 
Campbell Ritchie
Sheriff
Posts: 55292
156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum.

Remember to call setVisible last. Things altered after they become visible may not be displayed correctly.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!