• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Loading and unloading panels on one side of JSplitPane

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

I'm trying to create an application where on one side of a JSplitPane is the navigation and on the other side panels are loaded.

For example, on the left side, when i click Add Item, on the right side the panel that is for adding an item is displayed. If I click Options on the left side, the Add Item panel is unloaded from memory and the Options panel is loaded. I dont want to use CardLayout because I may have to use as many as 50 panels. Each panel is a different class.

The navigation is also also on a panel that is on the left side of the JSplitPane. On the right side also there is a panel which loads other external panels into it.

So how do I give command to the right side panel to load a specific panel? Any links to example applications with source also really appreciated.

Thanks
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "left" panel is going to have a listener of some sort that fires when the user selects something. More than likely this is an ActionListener, ListSelectionListener, TreeSelectionListener or something similar. Regardless of the listener, once you've detected the change all you need to do is retrieve the appropriate JPanel and change the right component by invoking setRightComponent(Component) on the JSplitPane.

For example:



Though I would consider that bad form in many ways, hopefully you get the idea.
 
reply
    Bookmark Topic Watch Topic
  • New Topic