JSplitPane
is used to divide two (and only two)
Component
s. The two
Component
s are graphically divided based on the look and feel implementation, and the two
Component
s can then be interactively resized by the user. Information on using
JSplitPane
is in
How to Use Split Panes in
The Java Tutorial .
The two Component
s in a split pane can be aligned left to right using JSplitPane.HORIZONTAL_SPLIT
, or top to bottom using JSplitPane.VERTICAL_SPLIT
. The preferred way to change the size of the Component
s is to invoke setDividerLocation
where location
is either the new x or y position, depending on the orientation of the JSplitPane
.
To resize the Component
s to their preferred sizes invoke resetToPreferredSizes
.
When the user is resizing the Component
s the minimum size of the Components
is used to determine the maximum/minimum position the Component
s can be set to. If the minimum size of the two components is greater than the size of the split pane the divider will not allow you to resize it. To alter the minimum size of a JComponent
, see JComponent.setMinimumSize(java.awt.Dimension)
.
When the user resizes the split pane the new space is distributed between the two components based on the resizeWeight
property. A value of 0, the default, indicates the right/bottom component gets all the space, where as a value of 1 indicates the left/top component gets all the space.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy .
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans
package. Please see XMLEncoder
.