File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JSplitPane (expandable closed) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JSplitPane (expandable closed)" Watch "JSplitPane (expandable closed)" New topic

JSplitPane (expandable closed)

Steve Ray

Joined: Jul 20, 2005
Posts: 3
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?
Swati Udas
Ranch Hand

Joined: Aug 18, 2004
Posts: 121
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 let the splitpanes be intermediate sizes and add JPanels in collapsed state at the corners.

Hope this helps !

SCJP 1.4 (90%)<br />SCWCD 1.4 (88%)
Steve Ray

Joined: Jul 20, 2005
Posts: 3
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.
I agree. Here's the link:
subject: JSplitPane (expandable closed)
It's not a secret anymore!