aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JSplitPane (expandable closed)" Watch "JSplitPane (expandable closed)" New topic
Author

JSplitPane (expandable closed)

Steve Ray
Greenhorn

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));
main.setMinimumSize(main.getPreferredSize());
JSplitPane spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
new JTextArea("Top pane"),
main);
spane.setOneTouchExpandable(true);
spane.setResizeWeight(0.);
spane.setDividerLocation(0.0);

JSplitPane spane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
new JTextArea("Left pane"),spane);
spane2.setOneTouchExpandable(true);
spane2.setResizeWeight(.0);
spane2.setDividerLocation(.0);

JSplitPane spane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,spane2,
new JTextArea("Right pane"));
spane3.setOneTouchExpandable(true);
spane3.setResizeWeight(1.0);
spane3.setDividerLocation(0);


JSplitPane spane4 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,spane3,
new JTextArea("Bottom pane"));
spane4.setOneTouchExpandable(true);
spane4.setResizeWeight(1.0);
spane4.setDividerLocation(0);

}
}

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 size..so 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
Greenhorn

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.
 
Consider Paul's rocket mass heater.
 
subject: JSplitPane (expandable closed)