Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Swing / AWT / SWT and the fly likes  Doubt in JFrame and loading Dynamic JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark " Doubt in JFrame and loading Dynamic JPanel" Watch " Doubt in JFrame and loading Dynamic JPanel" New topic

Doubt in JFrame and loading Dynamic JPanel

Anish Geo

Joined: Mar 09, 2009
Posts: 1
Hai Experts , I need some suggestions for the below scenario, my screen has two panels one is in left side & another is in right side of the screen.while opening the main screen I am having 3 buttons on the left side panel and none in the right side panel.If i clicked the 1st button 2 labels,2 text fields and 2 buttons should be displayed on the right side panel.I am having these components in a separate class file which extends a JPanel.Only in the run time i want to add this class file(as component) to the right side panel in the main screen.
Can any one guide how to make it possible?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10686

Welcome to the Ranch.

How are you dividing the left and right sides of your frame?Are you using JSplitPane?
Essentially what you need to do is add a listener to the buttons on the left panel. When the button is clicked, you need to set the appropriate panel to the right hand side.
Check out the JTabbedPane API on how to add/remove components.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Doubt in JFrame and loading Dynamic JPanel