Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adding multiple JPanels to a JFrame

807603Dec 4 2007 — edited Dec 5 2007
I want to be able to set up my interface so that it has two JPanels sat on the JFrame so when buttons on the first panel are clicked the second panel will update (will display different info). With one sat above the other, I know I could probably use one of the layout managers for this but I prefer absolute positioning as i'm not exactly sure how to use them properly.

I am trying to do this using absolute positioning to put the panels into the correct places but I get a nullPointerException when trying to call .setBounds() on the JPanels and am not quite sure how to proceed. I'm not quite sure how it can be pointing to nothing as I call the method on a specific panel and then use the add() method to place it onto the JFrame.

Thanks
Aaron
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2008
Added on Dec 4 2007
6 comments
340 views