javax.swing

Class JSplitPane

public class JSplitPane extends JComponent implements Accessible

This class implements JSplitPane. It is used to divide two components. By dragging the SplitPane's divider, the user can resize the two components. Note that the divider cannot resize a component to smaller than it's minimum size.
Nested Class Summary
protected classJSplitPane.AccessibleJSplitPane
Provides the accessibility features for the JSplitPane component.
Field Summary
static StringBOTTOM
The constraints string used to add components to the bottom.
protected booleancontinuousLayout
Whether the JSplitPane uses continuous layout.
static StringCONTINUOUS_LAYOUT_PROPERTY
The property fired when the continuousLayout property changes.
protected intdividerSize
The size of the divider.
static StringDIVIDER
The property fired when the divider property changes.
static StringDIVIDER_LOCATION_PROPERTY
The property fired when the divider location property changes.
static StringDIVIDER_SIZE_PROPERTY
The property fired when the divider size property changes.
static intHORIZONTAL_SPLIT
The value of the orientation when the components are split horizontally.
protected intlastDividerLocation
The last location of the divider given by the UI.
protected ComponentleftComponent
The component on the top or left.
static StringLAST_DIVIDER_LOCATION_PROPERTY
The property fired when the last divider location property changes.
static StringLEFT
The constraints string used to add components to the left.
protected booleanoneTouchExpandable
Whether the JSplitPane uses one touch expandable buttons.
protected intorientation
The orientation of the JSplitPane.
static StringONE_TOUCH_EXPANDABLE_PROPERTY
The property fired when the one touch expandable property changes.
static StringORIENTATION_PROPERTY
The property fired when the orientation property changes.
protected ComponentrightComponent
The component on the right or bottom.
static StringRESIZE_WEIGHT_PROPERTY
The property fired when the resize weight property changes.
static StringRIGHT
The constraints string used to add components to the right.
static StringTOP
The constraints string used to add components to the top.
static intVERTICAL_SPLIT
The value of the orientation when the components are split vertically.
Constructor Summary
JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane object with the given orientation, layout mode, and left and right components.
JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane object using nonContinuousLayout mode, the given orientation and left and right components.
JSplitPane(int newOrientation, boolean newContinuousLayout)
Creates a new JSplitPane object with the given layout mode and orientation.
JSplitPane(int newOrientation)
Creates a new JSplitPane object using a nonContinuousLayout mode and the given orientation.
JSplitPane()
Creates a new JSplitPane object using HORIZONTAL_SPLIT and a nonContinuousLayout mode.
Method Summary
protected voidaddImpl(Component comp, Object constraints, int index)
This method adds a component to the JSplitPane.
AccessibleContextgetAccessibleContext()
Returns the object that provides accessibility features for this JSplitPane component.
ComponentgetBottomComponent()
This method returns the bottom component.
intgetDividerLocation()
This method returns the location of the divider.
intgetDividerSize()
This method returns the size of the divider.
intgetLastDividerLocation()
This method returns the last divider location.
ComponentgetLeftComponent()
This method returns the left component.
intgetMaximumDividerLocation()
This method returns the maximum divider location.
intgetMinimumDividerLocation()
This method returns the minimum divider location.
intgetOrientation()
This method returns the orientation that the JSplitPane is using.
doublegetResizeWeight()
This method returns the current resize weight.
ComponentgetRightComponent()
This method returns the right component.
ComponentgetTopComponent()
This method returns the top component.
SplitPaneUIgetUI()
This method returns the UI.
StringgetUIClassID()
This method returns a string identifier to determine which UI class it needs.
booleanisContinuousLayout()
This method returns true if the JSplitPane is using a continuousLayout.
booleanisOneTouchExpandable()
This method returns true if the divider has one touch expandable buttons.
booleanisValidateRoot()
This method returns true.
protected voidpaintChildren(Graphics g)
This method overrides JComponent's paintChildren so the UI can be messaged when the children have finished painting.
protected StringparamString()
Returns an implementation-dependent string describing the attributes of this JSplitPane.
voidremove(Component component)
This method removes the given component from the JSplitPane.
voidremove(int index)
This method removes the component at the given index.
voidremoveAll()
This method removes all components from the JSplitPane.
voidresetToPreferredSizes()
This method resets all children of the JSplitPane to their preferred sizes.
voidsetBottomComponent(Component comp)
This method sets the bottom component.
voidsetContinuousLayout(boolean newContinuousLayout)
This method sets the layout mode for the JSplitPane.
voidsetDividerLocation(double proportionalLocation)
This method sets the location of the divider.
voidsetDividerLocation(int location)
This method sets the location of the divider.
voidsetDividerSize(int newSize)
This method sets the size of the divider.
voidsetLastDividerLocation(int newLastLocation)
This method sets the last location of the divider.
voidsetLeftComponent(Component comp)
This method sets the left component.
voidsetOneTouchExpandable(boolean newValue)
This method sets whether the divider has one touch expandable buttons.
voidsetOrientation(int orientation)
Sets the orientation for the JSplitPane and sends a {@link PropertyChangeEvent} (with the property name {@link #ORIENTATION_PROPERTY}) to all registered listeners.
voidsetResizeWeight(double value)
This method determines how extra space will be distributed among the left and right components.
voidsetRightComponent(Component comp)
This method sets the right component.
voidsetTopComponent(Component comp)
This method sets the top component.
voidsetUI(SplitPaneUI ui)
This method sets the UI used by the JSplitPane.
voidupdateUI()
This method resets the UI to the one specified by the current Look and Feel.

Field Detail

BOTTOM

public static final String BOTTOM
The constraints string used to add components to the bottom.

continuousLayout

protected boolean continuousLayout
Whether the JSplitPane uses continuous layout.

CONTINUOUS_LAYOUT_PROPERTY

public static final String CONTINUOUS_LAYOUT_PROPERTY
The property fired when the continuousLayout property changes.

dividerSize

protected int dividerSize
The size of the divider.

DIVIDER

public static final String DIVIDER
The property fired when the divider property changes.

DIVIDER_LOCATION_PROPERTY

public static final String DIVIDER_LOCATION_PROPERTY
The property fired when the divider location property changes.

DIVIDER_SIZE_PROPERTY

public static final String DIVIDER_SIZE_PROPERTY
The property fired when the divider size property changes.

HORIZONTAL_SPLIT

public static final int HORIZONTAL_SPLIT
The value of the orientation when the components are split horizontally.

lastDividerLocation

protected int lastDividerLocation
The last location of the divider given by the UI.

leftComponent

protected Component leftComponent
The component on the top or left.

LAST_DIVIDER_LOCATION_PROPERTY

public static final String LAST_DIVIDER_LOCATION_PROPERTY
The property fired when the last divider location property changes.

LEFT

public static final String LEFT
The constraints string used to add components to the left.

oneTouchExpandable

protected boolean oneTouchExpandable
Whether the JSplitPane uses one touch expandable buttons.

orientation

protected int orientation
The orientation of the JSplitPane.

ONE_TOUCH_EXPANDABLE_PROPERTY

public static final String ONE_TOUCH_EXPANDABLE_PROPERTY
The property fired when the one touch expandable property changes.

ORIENTATION_PROPERTY

public static final String ORIENTATION_PROPERTY
The property fired when the orientation property changes.

rightComponent

protected Component rightComponent
The component on the right or bottom.

RESIZE_WEIGHT_PROPERTY

public static final String RESIZE_WEIGHT_PROPERTY
The property fired when the resize weight property changes.

RIGHT

public static final String RIGHT
The constraints string used to add components to the right.

TOP

public static final String TOP
The constraints string used to add components to the top.

VERTICAL_SPLIT

public static final int VERTICAL_SPLIT
The value of the orientation when the components are split vertically.

Constructor Detail

JSplitPane

public JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane object with the given orientation, layout mode, and left and right components.

Parameters: newOrientation The orientation to use. newContinuousLayout The layout mode to use. newLeftComponent The left component. newRightComponent The right component.

Throws: IllegalArgumentException DOCUMENT ME!

JSplitPane

public JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane object using nonContinuousLayout mode, the given orientation and left and right components.

Parameters: newOrientation The orientation to use. newLeftComponent The left component. newRightComponent The right component.

JSplitPane

public JSplitPane(int newOrientation, boolean newContinuousLayout)
Creates a new JSplitPane object with the given layout mode and orientation.

Parameters: newOrientation The orientation to use. newContinuousLayout The layout mode to use.

JSplitPane

public JSplitPane(int newOrientation)
Creates a new JSplitPane object using a nonContinuousLayout mode and the given orientation.

Parameters: newOrientation The orientation to use.

JSplitPane

public JSplitPane()
Creates a new JSplitPane object using HORIZONTAL_SPLIT and a nonContinuousLayout mode.

Method Detail

addImpl

protected void addImpl(Component comp, Object constraints, int index)
This method adds a component to the JSplitPane. The constraints object is a string that identifies where this component should go. If the constraints is not a known one, it will throw an IllegalArgumentException. The valid constraints are LEFT, TOP, RIGHT, BOTTOM and DIVIDER.

Parameters: comp The component to add. constraints The constraints string to use. index Where to place to component in the list of components.

Throws: IllegalArgumentException When the constraints is not a known identifier.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Returns the object that provides accessibility features for this JSplitPane component.

Returns: The accessible context (an instance of {@link AccessibleJSplitPane}).

getBottomComponent

public Component getBottomComponent()
This method returns the bottom component.

Returns: The bottom component.

getDividerLocation

public int getDividerLocation()
This method returns the location of the divider. This method is passed to the UI.

Returns: The location of the divider.

getDividerSize

public int getDividerSize()
This method returns the size of the divider.

Returns: The size of the divider.

getLastDividerLocation

public int getLastDividerLocation()
This method returns the last divider location.

Returns: The last divider location.

getLeftComponent

public Component getLeftComponent()
This method returns the left component.

Returns: The left component.

getMaximumDividerLocation

public int getMaximumDividerLocation()
This method returns the maximum divider location. This method is passed to the UI.

Returns: DOCUMENT ME!

getMinimumDividerLocation

public int getMinimumDividerLocation()
This method returns the minimum divider location. This method is passed to the UI.

Returns: The minimum divider location.

getOrientation

public int getOrientation()
This method returns the orientation that the JSplitPane is using.

Returns: The current orientation.

getResizeWeight

public double getResizeWeight()
This method returns the current resize weight.

Returns: The current resize weight.

getRightComponent

public Component getRightComponent()
This method returns the right component.

Returns: The right component.

getTopComponent

public Component getTopComponent()
This method returns the top component.

Returns: The top component.

getUI

public SplitPaneUI getUI()
This method returns the UI.

Returns: The UI.

getUIClassID

public String getUIClassID()
This method returns a string identifier to determine which UI class it needs.

Returns: A string that identifies it's UI class.

isContinuousLayout

public boolean isContinuousLayout()
This method returns true if the JSplitPane is using a continuousLayout.

Returns: True if using a continuousLayout.

isOneTouchExpandable

public boolean isOneTouchExpandable()
This method returns true if the divider has one touch expandable buttons.

Returns: True if one touch expandable is used.

isValidateRoot

public boolean isValidateRoot()
This method returns true.

Returns: true.

paintChildren

protected void paintChildren(Graphics g)
This method overrides JComponent's paintChildren so the UI can be messaged when the children have finished painting.

Parameters: g The Graphics object to paint with.

paramString

protected String paramString()
Returns an implementation-dependent string describing the attributes of this JSplitPane.

Returns: A string describing the attributes of this JSplitPane (never null).

remove

public void remove(Component component)
This method removes the given component from the JSplitPane.

Parameters: component The Component to remove.

remove

public void remove(int index)
This method removes the component at the given index.

Parameters: index The index of the component to remove.

removeAll

public void removeAll()
This method removes all components from the JSplitPane.

resetToPreferredSizes

public void resetToPreferredSizes()
This method resets all children of the JSplitPane to their preferred sizes.

setBottomComponent

public void setBottomComponent(Component comp)
This method sets the bottom component.

Parameters: comp The Component to be placed at the bottom.

setContinuousLayout

public void setContinuousLayout(boolean newContinuousLayout)
This method sets the layout mode for the JSplitPane.

Parameters: newContinuousLayout Whether the JSplitPane is in continuousLayout mode.

setDividerLocation

public void setDividerLocation(double proportionalLocation)
This method sets the location of the divider. A value of 0 sets the divider to the farthest left. A value of 1 sets the divider to the farthest right.

Parameters: proportionalLocation A double that describes the location of the divider.

Throws: IllegalArgumentException if proportionalLocation is not in the range from 0.0 to 1.0 inclusive.

setDividerLocation

public void setDividerLocation(int location)
This method sets the location of the divider.

Parameters: location The location of the divider. The negative value forces to compute the new location from the preferred sizes of the split pane components.

setDividerSize

public void setDividerSize(int newSize)
This method sets the size of the divider.

Parameters: newSize The size of the divider.

setLastDividerLocation

public void setLastDividerLocation(int newLastLocation)
This method sets the last location of the divider.

Parameters: newLastLocation The last location of the divider.

setLeftComponent

public void setLeftComponent(Component comp)
This method sets the left component.

Parameters: comp The left component.

setOneTouchExpandable

public void setOneTouchExpandable(boolean newValue)
This method sets whether the divider has one touch expandable buttons. The one touch expandable buttons can expand the size of either component to the maximum allowed size.

Parameters: newValue Whether the divider will have one touch expandable buttons.

setOrientation

public void setOrientation(int orientation)
Sets the orientation for the JSplitPane and sends a {@link PropertyChangeEvent} (with the property name {@link #ORIENTATION_PROPERTY}) to all registered listeners.

Parameters: orientation the orientation (either {@link #HORIZONTAL_SPLIT} or {@link #VERTICAL_SPLIT}).

Throws: IllegalArgumentException if orientation is not one of the listed values.

setResizeWeight

public void setResizeWeight(double value)
This method determines how extra space will be distributed among the left and right components. A value of 0 will allocate all extra space to the right component. A value of 1 indicates that all extra space will go to the left component. A value in between 1 and 0 will split the space accordingly.

Parameters: value The resize weight.

setRightComponent

public void setRightComponent(Component comp)
This method sets the right component.

Parameters: comp The right component.

setTopComponent

public void setTopComponent(Component comp)
This method sets the top component.

Parameters: comp The top component.

setUI

public void setUI(SplitPaneUI ui)
This method sets the UI used by the JSplitPane.

Parameters: ui The UI to use.

updateUI

public void updateUI()
This method resets the UI to the one specified by the current Look and Feel.