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

Assigning a JPanel to a new JPanel obejct!  RSS feed

 
Zee Tuff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something is bugging me! Here is the process:

1. Create panel and add a component to it
2. Add the panel to a frame
3. Create a new panel with a new component
4. Assign the new panel to the old panel
5. repaint

and nothing happens! Shouldn't the panel be updated?

Help is appreciated.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"green apple", please check your private messages for an important administrative matter.
 
Rob Spoor
Sheriff
Posts: 21044
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you add your new JPanel to the JFrame? Remember, Java is pass-by-value, so the JFrame still has a reference to the old JPanel object after the assignment.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!