Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Doubt in JFrame and loading Dynamic JPanel

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anish,
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.
 
I knew I would regret that burrito. But this tiny ad has never caused regrets:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic