javax.swing
Class JSplitPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JSplitPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

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.

See Also:
Serialized Form

Nested Class Summary
protected  class JSplitPane.AccessibleJSplitPane
          Provides the accessibility features for the JSplitPane component.
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String BOTTOM
          The constraints string used to add components to the bottom.
static String CONTINUOUS_LAYOUT_PROPERTY
          The property fired when the continuousLayout property changes.
protected  boolean continuousLayout
          Whether the JSplitPane uses continuous layout.
static String DIVIDER
          The property fired when the divider property changes.
static String DIVIDER_LOCATION_PROPERTY
          The property fired when the divider location property changes.
static String DIVIDER_SIZE_PROPERTY
          The property fired when the divider size property changes.
protected  int dividerSize
          The size of the divider.
static int HORIZONTAL_SPLIT
          The value of the orientation when the components are split horizontally.
static String LAST_DIVIDER_LOCATION_PROPERTY
          The property fired when the last divider location property changes.
protected  int lastDividerLocation
          The last location of the divider given by the UI.
static String LEFT
          The constraints string used to add components to the left.
protected  Component leftComponent
          The component on the top or left.
static String ONE_TOUCH_EXPANDABLE_PROPERTY
          The property fired when the one touch expandable property changes.
protected  boolean oneTouchExpandable
          Whether the JSplitPane uses one touch expandable buttons.
protected  int orientation
          The orientation of the JSplitPane.
static String ORIENTATION_PROPERTY
          The property fired when the orientation property changes.
static String RESIZE_WEIGHT_PROPERTY
          The property fired when the resize weight property changes.
static String RIGHT
          The constraints string used to add components to the right.
protected  Component rightComponent
          The component on the right or bottom.
static String TOP
          The constraints string used to add components to the top.
static int VERTICAL_SPLIT
          The value of the orientation when the components are split vertically.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JSplitPane()
          Creates a new JSplitPane object using HORIZONTAL_SPLIT and a nonContinuousLayout mode.
JSplitPane(int newOrientation)
          Creates a new JSplitPane object using a nonContinuousLayout mode and the given orientation.
JSplitPane(int newOrientation, boolean newContinuousLayout)
          Creates a new JSplitPane object with the given layout mode and orientation.
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.
 
Method Summary
protected  void addImpl(Component comp, Object constraints, int index)
          This method adds a component to the JSplitPane.
 AccessibleContext getAccessibleContext()
          Returns the object that provides accessibility features for this JSplitPane component.
 Component getBottomComponent()
          This method returns the bottom component.
 int getDividerLocation()
          This method returns the location of the divider.
 int getDividerSize()
          This method returns the size of the divider.
 int getLastDividerLocation()
          This method returns the last divider location.
 Component getLeftComponent()
          This method returns the left component.
 int getMaximumDividerLocation()
          This method returns the maximum divider location.
 int getMinimumDividerLocation()
          This method returns the minimum divider location.
 int getOrientation()
          This method returns the orientation that the JSplitPane is using.
 double getResizeWeight()
          This method returns the current resize weight.
 Component getRightComponent()
          This method returns the right component.
 Component getTopComponent()
          This method returns the top component.
 SplitPaneUI getUI()
          This method returns the UI.
 String getUIClassID()
          This method returns a string identifier to determine which UI class it needs.
 boolean isContinuousLayout()
          This method returns true if the JSplitPane is using a continuousLayout.
 boolean isOneTouchExpandable()
          This method returns true if the divider has one touch expandable buttons.
 boolean isValidateRoot()
          This method returns true.
protected  void paintChildren(Graphics g)
          This method overrides JComponent's paintChildren so the UI can be messaged when the children have finished painting.
protected  String paramString()
          Returns an implementation-dependent string describing the attributes of this JSplitPane.
 void remove(Component component)
          This method removes the given component from the JSplitPane.
 void remove(int index)
          This method removes the component at the given index.
 void removeAll()
          This method removes all components from the JSplitPane.
 void resetToPreferredSizes()
          This method resets all children of the JSplitPane to their preferred sizes.
 void setBottomComponent(Component comp)
          This method sets the bottom component.
 void setContinuousLayout(boolean newContinuousLayout)
          This method sets the layout mode for the JSplitPane.
 void setDividerLocation(double proportionalLocation)
          This method sets the location of the divider.
 void setDividerLocation(int location)
          This method sets the location of the divider.
 void setDividerSize(int newSize)
          This method sets the size of the divider.
 void setLastDividerLocation(int newLastLocation)
          This method sets the last location of the divider.
 void setLeftComponent(Component comp)
          This method sets the left component.
 void setOneTouchExpandable(boolean newValue)
          This method sets whether the divider has one touch expandable buttons.
 void setOrientation(int orientation)
          Sets the orientation for the JSplitPane and sends a PropertyChangeEvent (with the property name ORIENTATION_PROPERTY) to all registered listeners.
 void setResizeWeight(double value)
          This method determines how extra space will be distributed among the left and right components.
 void setRightComponent(Component comp)
          This method sets the right component.
 void setTopComponent(Component comp)
          This method sets the top component.
 void setUI(SplitPaneUI ui)
          This method sets the UI used by the JSplitPane.
 void updateUI()
          This method resets the UI to the one specified by the current Look and Feel.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BOTTOM

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

See Also:
Constant Field Values

CONTINUOUS_LAYOUT_PROPERTY

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

See Also:
Constant Field Values

DIVIDER

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

See Also:
Constant Field Values

DIVIDER_LOCATION_PROPERTY

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

See Also:
Constant Field Values

DIVIDER_SIZE_PROPERTY

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

See Also:
Constant Field Values

HORIZONTAL_SPLIT

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

See Also:
Constant Field Values

LAST_DIVIDER_LOCATION_PROPERTY

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

See Also:
Constant Field Values

LEFT

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

See Also:
Constant Field Values

ONE_TOUCH_EXPANDABLE_PROPERTY

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

See Also:
Constant Field Values

ORIENTATION_PROPERTY

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

See Also:
Constant Field Values

RESIZE_WEIGHT_PROPERTY

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

See Also:
Constant Field Values

RIGHT

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

See Also:
Constant Field Values

TOP

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

See Also:
Constant Field Values

VERTICAL_SPLIT

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

See Also:
Constant Field Values

continuousLayout

protected boolean continuousLayout
Whether the JSplitPane uses continuous layout.


oneTouchExpandable

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


dividerSize

protected int dividerSize
The size of the divider.


lastDividerLocation

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


orientation

protected int orientation
The orientation of the JSplitPane.


leftComponent

protected Component leftComponent
The component on the top or left.


rightComponent

protected Component rightComponent
The component on the right or bottom.

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.

Overrides:
addImpl in class Container
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.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
The accessible context (an instance of JSplitPane.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.

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.

Overrides:
isValidateRoot in class JComponent
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.

Overrides:
paintChildren in class JComponent
Parameters:
g - The Graphics object to paint with.
See Also:
JComponent.paint(java.awt.Graphics), JComponent.paintBorder(java.awt.Graphics), JComponent.paintComponent(java.awt.Graphics)

paramString

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

Overrides:
paramString in class JComponent
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.

Overrides:
remove in class Container
Parameters:
component - The Component to remove.

remove

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

Overrides:
remove in class Container
Parameters:
index - The index of the component to remove.

removeAll

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

Overrides:
removeAll in class Container

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 PropertyChangeEvent (with the property name ORIENTATION_PROPERTY) to all registered listeners.

Parameters:
orientation - the orientation (either HORIZONTAL_SPLIT or 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.

Overrides:
updateUI in class JComponent

getUIClassID

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

Overrides:
getUIClassID in class JComponent
Returns:
A string that identifies it's UI class.
See Also:
JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()