• Post Reply Bookmark Topic Watch Topic
  • New Topic

hide splitpane divider  RSS feed

 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a splitpane with two panels. I want the bottom panel to be shown only when the user does some action. So, initially the splitpae divider should be at the hidden. Can we hide the splitpane divider so that the user can not drag the splitpane's top bottom to make the bottom panel visible.
Thanks
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can:
1. programmatically set the divider location to be all the way at the bottom. I think you can override the behavior when someone moves it to a new location (by setting it back to the bottom).
2. don't use a splitpane until the action is done by the user. then remove the contents of the panel from its parent Container, add a JSplitPane, and add the panel you just removed to the split pane. This should be doable.
3. Not sure if this will work, but you can try setting the max height of the bottom content to 0 or 1, then reverting it when you need to. (Based on previous experience with Swing's layout managers, I don't have too much faith in this.)
4. If you don't actually need a split pane (user-movable divider) use can do all sorts of things, especially similar to #2.
Bill
 
pavan in
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,
Is it possible to hide the panel rather than removing it from the applet's content pane? so that I can make it visible when the user closes the bottom panel later.
and, is it necessary for the JTree to be added to scollpane or can I add JTree directly to the panel.what are the pro's and cons?
Thanks
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CardLayout is the Layout to switch between different Components such as JPanels or JSplitPanes.
If you do not put the JTree into a JScrollPane it won't be scrollable if it is to big for the window. Thus, the user won't be able to see the hidden parts of it.
If you are sure, that the JTree will always fit into the view than you can skip the JScrollPane. On the other hand, the scrollpane is (default) not visible until it needs to be. so it won't hurt to put it in, and you'll be on the safe side.
Chantal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!