Spec-Zone .ru
спецификации, руководства, описания, API
JavaTM 2 Platform
Standard Edition

javax.swing
Class JSplitPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JSplitPane

public class JSplitPane
extends JComponent
implements Accessible

JSplitPane is used to divide two (and only two) Components. The two Components are graphically divided based on the look and feel implementation, and the two Components can then be interactively resized by the user.

The two Components 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 Components is to invoke setDividerLocation where location is either the new x or y position, depending on the orientation of the JSplitPane. If one component changes, JSplitPane also attempts to reposition the other component.

To resize the Components to their preferred sizes invoke resetToPreferredSizes.

When the user is resizing the Components the minimum size of the Components is used to determine the maximum/minimum position the Components can be set to. So that if the minimum size of the two components is greater than the size of the splitpane the divider will not allow you to resize it. To alter the minimum size of a JComponent, see JComponent.setMinimumSize(java.awt.Dimension).

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JSplitPane key assignments.

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. A future release of Swing will provide support for long term persistence.

See Also:
setDividerLocation(double), resetToPreferredSizes(), Serialized Form

Inner Class Summary
protected  class JSplitPane.AccessibleJSplitPane
          The class used to obtain the accessible role for this object.
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
static String BOTTOM
          Used to add a Component below the other Component.
static String CONTINUOUS_LAYOUT_PROPERTY
          Bound property name for continuousLayout.
protected  boolean continuousLayout
          Whether or not the views are continuously redisplayed while resizing.
static String DIVIDER
          Used to add a Component that will represent the divider.
static String DIVIDER_SIZE_PROPERTY
          Bound property name for border.
protected  int dividerSize
          Size of the divider.
static int HORIZONTAL_SPLIT
          Horizontal split indicates the Components are split along the x axis, eg the two Components will be split one to the left of the other.
static String LAST_DIVIDER_LOCATION_PROPERTY
          Bound property for lastLocation.
protected  int lastDividerLocation
          Previous location of the split pane.
static String LEFT
          Used to add a Component to the left of the other Component.
protected  Component leftComponent
          The left or top component.
static String ONE_TOUCH_EXPANDABLE_PROPERTY
          Bound property for oneTouchExpandable.
protected  boolean oneTouchExpandable
          Is a little widget provided to quickly expand/collapse the split pane?
protected  int orientation
          How the views are split.
static String ORIENTATION_PROPERTY
          Bound property name for orientation (horizontal or vertical).
static String RIGHT
          Used to add a Component to the right of the other Component.
protected  Component rightComponent
          The right or bottom component.
static String TOP
          Used to add a Component above the other Component.
static int VERTICAL_SPLIT
          Vertical split indicates the Components are split along the y axis, eg the two Components will be split one on top of the other.
 
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
 
Constructor Summary
JSplitPane()
          Returns a new JSplitPane configured to arrange the child components side-by-side horizontally with no continuous layout, using two buttons for the compoents.
JSplitPane(int newOrientation)
          Returns a new JSplitPane configured with the specified orientation and no continuous layout.
JSplitPane(int newOrientation, boolean newContinuousLayout)
          Returns a new JSplitPane with the specified orientation and redrawing style.
JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
          Returns a new JSplitPane with the specified orientation and redrawing style, and with the specified components.
JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
          Returns a new JSplitPane with the specified orientation and with the specifiied components that does not do continuous redrawing.
 
Method Summary
protected  void addImpl(Component comp, Object constraints, int index)
          If constraints identifies the left/top or right/bottom child component, and a component with that identifier was previously added, it will be removed and then comp will be added in its place.
 AccessibleContext getAccessibleContext()
          Get the AccessibleContext associated with this JComponent
 Component getBottomComponent()
          Returns the component below, or to the right of the divider.
 int getDividerLocation()
          Returns the location of the divider from the look and feel implementation.
 int getDividerSize()
          Returns the size of the divider.
 int getLastDividerLocation()
          Returns the last location the divider was at.
 Component getLeftComponent()
          Returns the component to the left (or above) the divider.
 int getMaximumDividerLocation()
          Returns the maximum location of the divider from the look and feel implementation.
 int getMinimumDividerLocation()
          Returns the minimum location of the divider from the look and feel implementation.
 int getOrientation()
          Returns the orientation.
 Component getRightComponent()
          Returns the component to the right (or below) the divider.
 Component getTopComponent()
          Returns the component above, or to the left of the divider.
 SplitPaneUI getUI()
          Returns the SplitPaneUI that is providing the current look and feel.
 String getUIClassID()
          Returns the name of the L&F class that renders this component.
 boolean isContinuousLayout()
          Returns true if the child comopnents are continuously redisplayed and layed out during user intervention.
 boolean isOneTouchExpandable()
          Returns true if the pane provides a UI widget to collapse/expand the divider.
 boolean isValidateRoot()
          Calls to revalidate() on any descendant of this JSplitPane, will cause a request to be queued that will validate the JSplitPane and all its descendants.
protected  void paintChildren(Graphics g)
          Subclassed to message the UI with finishedPaintingChildren after super has been messaged, as well as painting the border.
protected  String paramString()
          Returns a string representation of this JSplitPane.
 void remove(Component component)
          Removes the child component, component from the pane.
 void remove(int index)
          Removes the Component at the specified index.
 void removeAll()
          Removes all the child components from the receiver.
 void resetToPreferredSizes()
          Messaged to relayout the JSplitPane based on the preferred size of the children components.
 void setBottomComponent(Component comp)
          Sets the component below, or to the right of the divider.
 void setContinuousLayout(boolean newContinuousLayout)
          Sets whether or not the child components are continuously redisplayed and layed out during user intervention.
 void setDividerLocation(double proportionalLocation)
          Sets the divider location as a percentage of the JSplitPane's size.
 void setDividerLocation(int location)
          Sets the location of the divider.
 void setDividerSize(int newSize)
          Sets the size of the divider.
 void setLastDividerLocation(int newLastLocation)
          Sets the last location the divider was at to newLastLocation.
 void setLeftComponent(Component comp)
          Sets the component to the left (or above) the divider.
 void setOneTouchExpandable(boolean newValue)
          Determines whether the JSplitPane provides a UI widget on the divider to quickly expand/collapse the divider.
 void setOrientation(int orientation)
          Sets the orientation, or how the splitter is divided.
 void setRightComponent(Component comp)
          Sets the component to the right (or below) the divider.
 void setTopComponent(Component comp)
          Sets the component above, or to the left of the divider.
 void setUI(SplitPaneUI ui)
          Sets the L&F object that renders this component.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERTICAL_SPLIT

public static final int VERTICAL_SPLIT
Vertical split indicates the Components are split along the y axis, eg the two Components will be split one on top of the other.

HORIZONTAL_SPLIT

public static final int HORIZONTAL_SPLIT
Horizontal split indicates the Components are split along the x axis, eg the two Components will be split one to the left of the other.

LEFT

public static final String LEFT
Used to add a Component to the left of the other Component.

RIGHT

public static final String RIGHT
Used to add a Component to the right of the other Component.

TOP

public static final String TOP
Used to add a Component above the other Component.

BOTTOM

public static final String BOTTOM
Used to add a Component below the other Component.

DIVIDER

public static final String DIVIDER
Used to add a Component that will represent the divider.

ORIENTATION_PROPERTY

public static final String ORIENTATION_PROPERTY
Bound property name for orientation (horizontal or vertical).

CONTINUOUS_LAYOUT_PROPERTY

public static final String CONTINUOUS_LAYOUT_PROPERTY
Bound property name for continuousLayout.

DIVIDER_SIZE_PROPERTY

public static final String DIVIDER_SIZE_PROPERTY
Bound property name for border.

ONE_TOUCH_EXPANDABLE_PROPERTY

public static final String ONE_TOUCH_EXPANDABLE_PROPERTY
Bound property for oneTouchExpandable.

LAST_DIVIDER_LOCATION_PROPERTY

public static final String LAST_DIVIDER_LOCATION_PROPERTY
Bound property for lastLocation.

orientation

protected int orientation
How the views are split.

continuousLayout

protected boolean continuousLayout
Whether or not the views are continuously redisplayed while resizing.

leftComponent

protected Component leftComponent
The left or top component.

rightComponent

protected Component rightComponent
The right or bottom component.

dividerSize

protected int dividerSize
Size of the divider.

oneTouchExpandable

protected boolean oneTouchExpandable
Is a little widget provided to quickly expand/collapse the split pane?

lastDividerLocation

protected int lastDividerLocation
Previous location of the split pane.
Constructor Detail

JSplitPane

public JSplitPane()
Returns a new JSplitPane configured to arrange the child components side-by-side horizontally with no continuous layout, using two buttons for the compoents.

JSplitPane

public JSplitPane(int newOrientation)
Returns a new JSplitPane configured with the specified orientation and no continuous layout.
Parameters:
newOrientation - an int specifying the horizontal or vertical orientation

JSplitPane

public JSplitPane(int newOrientation,
                  boolean newContinuousLayout)
Returns a new JSplitPane with the specified orientation and redrawing style.
Parameters:
newOrientation - an int specifying the horizontal or vertical orientation
newContinuousLayout - a boolean, true for the components to redraw continuously as the divider changes position, false to wait until the divider position stops changing to redraw

JSplitPane

public JSplitPane(int newOrientation,
                  Component newLeftComponent,
                  Component newRightComponent)
Returns a new JSplitPane with the specified orientation and with the specifiied components that does not do continuous redrawing.
Parameters:
newOrientation - an int specifying the horizontal or vertical orientation
newContinuousLayout - a boolean, true for the components to redraw continuously as the divider changes position, false to wait until the divider position stops changing to redraw
newLeftComponent - the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane.

JSplitPane

public JSplitPane(int newOrientation,
                  boolean newContinuousLayout,
                  Component newLeftComponent,
                  Component newRightComponent)
Returns a new JSplitPane with the specified orientation and redrawing style, and with the specified components.
Parameters:
newOrientation - an int specifying the horizontal or vertical orientation
newContinuousLayout - a boolean, true for the components to redraw continuously as the divider changes position, false to wait until the divider position stops changing to redraw
newLeftComponent - the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane.
Method Detail

setUI

public void setUI(SplitPaneUI ui)
Sets the L&F object that renders this component.
Parameters:
ui - the SplitPaneUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

getUI

public SplitPaneUI getUI()
Returns the SplitPaneUI that is providing the current look and feel.
Returns:
the SplitPaneUI object that renders this component

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
Returns the name of the L&F class that renders this component.
Overrides:
getUIClassID in class JComponent
Returns:
"SplitPaneUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setDividerSize

public void setDividerSize(int newSize)
Sets the size of the divider.
Parameters:
newSize - an int giving the size of the divider in pixels

getDividerSize

public int getDividerSize()
Returns the size of the divider.
Returns:
an int giving the size of the divider in pixels

setLeftComponent

public void setLeftComponent(Component comp)
Sets the component to the left (or above) the divider.
Parameters:
comp - the Component to display in that position

getLeftComponent

public Component getLeftComponent()
Returns the component to the left (or above) the divider.
Returns:
the Component displayed in that position

setTopComponent

public void setTopComponent(Component comp)
Sets the component above, or to the left of the divider.
Parameters:
comp - the Component to display in that position

getTopComponent

public Component getTopComponent()
Returns the component above, or to the left of the divider.
Returns:
the Component displayed in that position

setRightComponent

public void setRightComponent(Component comp)
Sets the component to the right (or below) the divider.
Parameters:
comp - the Component to display in that position

getRightComponent

public Component getRightComponent()
Returns the component to the right (or below) the divider.
Returns:
the Component displayed in that position

setBottomComponent

public void setBottomComponent(Component comp)
Sets the component below, or to the right of the divider.
Parameters:
comp - the Component to display in that position

getBottomComponent

public Component getBottomComponent()
Returns the component below, or to the right of the divider.
Returns:
the Component displayed in that position

setOneTouchExpandable

public void setOneTouchExpandable(boolean newValue)
Determines whether the JSplitPane provides a UI widget on the divider to quickly expand/collapse the divider.
Parameters:
newValue - a boolean, where true means to provide a collapse/expand widget

isOneTouchExpandable

public boolean isOneTouchExpandable()
Returns true if the pane provides a UI widget to collapse/expand the divider.
Returns:
true if the split pane provides a collapse/expand widget

setLastDividerLocation

public void setLastDividerLocation(int newLastLocation)
Sets the last location the divider was at to newLastLocation.
Parameters:
newLastLocation - an int specifying the last divider location in pixels, from the left (or upper) edge of the pane to the left (or upper) edge of the divider

getLastDividerLocation

public int getLastDividerLocation()
Returns the last location the divider was at.
Returns:
an int specifying the last divider location as a count of pixels from the left (or upper) edge of the pane to the left (or upper) edge of the divider

setOrientation

public void setOrientation(int orientation)
Sets the orientation, or how the splitter is divided. The options are:
Parameters:
orientation - an int specifying the orientation

getOrientation

public int getOrientation()
Returns the orientation.
Returns:
an int giving the orientation
See Also:
setOrientation(int)

setContinuousLayout

public void setContinuousLayout(boolean newContinuousLayout)
Sets whether or not the child components are continuously redisplayed and layed out during user intervention.
Parameters:
newContinuousLayout - a boolean, true if the components are continuously redrawn as the divider changes position

isContinuousLayout

public boolean isContinuousLayout()
Returns true if the child comopnents are continuously redisplayed and layed out during user intervention.
Returns:
true if the components are continuously redrawn as the divider changes position

resetToPreferredSizes

public void resetToPreferredSizes()
Messaged to relayout the JSplitPane based on the preferred size of the children components.

setDividerLocation

public void setDividerLocation(double proportionalLocation)
Sets the divider location as a percentage of the JSplitPane's size.
Parameters:
proportionalLocation - a double-precision floating point value that specifies a percentage, from zero (top/left) to 1.0 (bottom/right)
Throws:
IllegalArgumentException - if the specified location is < 0 or > 1.0

setDividerLocation

public void setDividerLocation(int location)
Sets the location of the divider. This is passed off to the look and feel implementation.
Parameters:
location - an int specifying a UI-specific value (typically a pixel count)

getDividerLocation

public int getDividerLocation()
Returns the location of the divider from the look and feel implementation.
Returns:
an int specifying a UI-specific value (typically a pixel count)

getMinimumDividerLocation

public int getMinimumDividerLocation()
Returns the minimum location of the divider from the look and feel implementation.
Returns:
an int specifying a UI-specific value for the minimum location (typically a pixel count)

getMaximumDividerLocation

public int getMaximumDividerLocation()
Returns the maximum location of the divider from the look and feel implementation.
Returns:
an int specifying a UI-specific value for the maximum location (typically a pixel count)

remove

public void remove(Component component)
Removes the child component, component from the pane. Resets the leftComponent or rightComponent instance variable, as necessary.
Overrides:
remove in class Container
Parameters:
component - the Component to remove

remove

public void remove(int index)
Removes the Component at the specified index. Updates the leftComponent and rightComponent instance variables as necessary, and then messages super.
Overrides:
remove in class Container
Parameters:
index - an int specifying the component to remove, where 1 specifies the left/top component and 2 specifies the bottom/right component

removeAll

public void removeAll()
Removes all the child components from the receiver. Resets the leftComonent and rightComponent instance variables.
Overrides:
removeAll in class Container
Tags copied from class: Container
See Also:
Container.add(java.awt.Component), Container.remove(int)

isValidateRoot

public boolean isValidateRoot()
Calls to revalidate() on any descendant of this JSplitPane, will cause a request to be queued that will validate the JSplitPane and all its descendants.
Overrides:
isValidateRoot in class JComponent
Returns:
true
See Also:
JComponent.revalidate()

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
If constraints identifies the left/top or right/bottom child component, and a component with that identifier was previously added, it will be removed and then comp will be added in its place. If constraints is not one of the known identifers the layout manager may throw an IllegalArgumentException.

The possible constraints objects (Strings) are:

If the constraints object is null, the component is added in the first available position (left/top if open, else right/bottom).
Overrides:
addImpl in class Container
Parameters:
comp - the component to add
constraints - an Object specifying the layout constraints (position) for this component
index - an int specifying the index in the container's list.
Throws:
IllegalArgumentException - thrown if the constraints object does not match an existing component
See Also:
Container.addImpl(Component, Object, int)

paintChildren

protected void paintChildren(Graphics g)
Subclassed to message the UI with finishedPaintingChildren after super has been messaged, as well as painting the border.
Overrides:
paintChildren in class JComponent
Parameters:
g - the Graphics context within which to paint

paramString

protected String paramString()
Returns a string representation of this JSplitPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class JComponent
Returns:
a string representation of this JSplitPane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
the AccessibleContext of this JComponent

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.