• 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

JSplitPane (expandable closed)

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I create a JSplitPane with oneTouchExpandable(true) but I want the panel to be collapsed when first displayed. I want to create a panel with collapsed panels on all 4 sides. Imagine a border layout with a panel in the middle and different panels on all four sides but collapsed. I have tried the following but doesn't work completly:

import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;

public class SplitpaneTest {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(new Dimension(600,600));
JPanel main = new JPanel();
main.setSize(new Dimension(500,500));
JSplitPane spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JTextArea("Top pane"),

JSplitPane spane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JTextArea("Left pane"),spane);

JSplitPane spane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,spane2,
new JTextArea("Right pane"));

JSplitPane spane4 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,spane3,
new JTextArea("Bottom pane"));


Any ideas?
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as i understand the requirement is -->

A splitpane with 4 panes.. one at each corner of a frame..all four shud look collapsed at the begining and should occupy 4 sections of the splitpane when expanded.!

I think u can add a Panel to each section of the splitpane and leave it collapsed.
Even if u have setdividerlocation=0.. one pane will be collapsed but the other side will show max size..so let the splitpanes be intermediate sizes and add JPanels in collapsed state at the corners.

Hope this helps !
Steve Ray
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand your suggestion, can you give me a little more detail?

As you can see in my example, there are 5 panels, the center one should be open and the panels on the four sides should be colapsed. I thought that I could do that by setting the dividerposition and setting the weights of either panel.
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic