JSplitPane (Java Platform SE 6) (original) (raw)
javax.swing
Class JSplitPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSplitPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
public class JSplitPane
extends JComponent
implements Accessible
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 inHow to Use Split Panes in The Java Tutorial.
The two Component
s in a split pane can be aligned left to right usingJSplitPane.HORIZONTAL_SPLIT
, or top to bottom using JSplitPane.VERTICAL_SPLIT
. The preferred way to change the size of the Component
s is to invokesetDividerLocation
where location
is either the new x or y position, depending on the orientation of theJSplitPane
.
To resize the Component
s to their preferred sizes invokeresetToPreferredSizes
.
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 aJComponent
, 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 JavaBeansTM has been added to the java.beans
package. Please see XMLEncoder.
See Also:
setDividerLocation(double), resetToPreferredSizes()
Nested Class Summary | |
---|---|
protected class | JSplitPane.AccessibleJSplitPane This class implements accessibility support for the JSplitPane class. |
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String | BOTTOM Used to add a Component below the otherComponent. |
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_LOCATION_PROPERTY Bound property for the dividerLocation. |
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. |
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 otherComponent. |
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 | RESIZE_WEIGHT_PROPERTY Bound property for weight. |
static String | RIGHT Used to add a Component to the right of the otherComponent. |
protected Component | rightComponent The right or bottom component. |
static String | TOP Used to add a Component above the otherComponent. |
static int | VERTICAL_SPLIT Vertical split indicates the Components are split along the y axis. |
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 configured to arrange the child components side-by-side horizontally with no continuous layout, using two buttons for the components. |
JSplitPane(int newOrientation) Creates a new JSplitPane configured with the specified orientation and no continuous layout. |
[JSplitPane](../../javax/swing/JSplitPane.html#JSplitPane%28int, boolean%29)(int newOrientation, boolean newContinuousLayout) Creates a new JSplitPane with the specified orientation and redrawing style. |
[JSplitPane](../../javax/swing/JSplitPane.html#JSplitPane%28int, boolean, java.awt.Component, java.awt.Component%29)(int newOrientation, boolean newContinuousLayout,Component newLeftComponent,Component newRightComponent) Creates a new JSplitPane with the specified orientation and redrawing style, and with the specified components. |
[JSplitPane](../../javax/swing/JSplitPane.html#JSplitPane%28int, java.awt.Component, java.awt.Component%29)(int newOrientation,Component newLeftComponent,Component newRightComponent) Creates a new JSplitPane with the specified orientation and with the specified components that do not do continuous redrawing. |
Method Summary | |
---|---|
protected void | [addImpl](../../javax/swing/JSplitPane.html#addImpl%28java.awt.Component, java.lang.Object, int%29)(Component comp,Object constraints, int index) Adds the specified component to this split pane. |
AccessibleContext | getAccessibleContext() Gets the AccessibleContext associated with this JSplitPane. |
Component | getBottomComponent() Returns the component below, or to the right of the divider. |
int | getDividerLocation() Returns the last value passed to setDividerLocation. |
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. |
double | getResizeWeight() Returns the number that determines how extra space is distributed. |
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() Gets the continuousLayout property. |
boolean | isOneTouchExpandable() Gets the oneTouchExpandable property. |
boolean | isValidateRoot() Returns true, so that 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 split pane. |
void | resetToPreferredSizes() Lays out the JSplitPane layout 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 the value of the continuousLayout property, which must be true for the child components to be continuously redisplayed and laid out during user intervention. |
void | setDividerLocation(double proportionalLocation) Sets the divider location as a percentage of theJSplitPane'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 tonewLastLocation. |
void | setLeftComponent(Component comp) Sets the component to the left (or above) the divider. |
void | setOneTouchExpandable(boolean newValue) Sets the value of the oneTouchExpandable property, which must be true for theJSplitPane to provide 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 | setResizeWeight(double value) Specifies how to distribute extra space when the size of the split pane changes. |
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, addVetoableChangeListener, computeVisibleRect, [contains](../../javax/swing/JComponent.html#contains%28int, int%29), createToolTip, disable, enable, [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, boolean, boolean%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, char, char%29), [firePropertyChange](../../javax/swing/JComponent.html#firePropertyChange%28java.lang.String, int, int%29), [fireVetoableChange](../../javax/swing/JComponent.html#fireVetoableChange%28java.lang.String, java.lang.Object, java.lang.Object%29), getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, [getBaseline](../../javax/swing/JComponent.html#getBaseline%28int, int%29), getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintComponent, [paintImmediately](../../javax/swing/JComponent.html#paintImmediately%28int, int, int, int%29), paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, [processKeyBinding](../../javax/swing/JComponent.html#processKeyBinding%28javax.swing.KeyStroke, java.awt.event.KeyEvent, int, boolean%29), processKeyEvent, processMouseEvent, processMouseMotionEvent, [putClientProperty](../../javax/swing/JComponent.html#putClientProperty%28java.lang.Object, java.lang.Object%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, javax.swing.KeyStroke, int%29), [registerKeyboardAction](../../javax/swing/JComponent.html#registerKeyboardAction%28java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int%29), removeAncestorListener, removeNotify, removeVetoableChangeListener, [repaint](../../javax/swing/JComponent.html#repaint%28long, int, int, int, int%29), repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, [reshape](../../javax/swing/JComponent.html#reshape%28int, int, int, int%29), revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, [setFocusTraversalKeys](../../javax/swing/JComponent.html#setFocusTraversalKeys%28int, java.util.Set%29), setFont, setForeground, setInheritsPopupMenu, [setInputMap](../../javax/swing/JComponent.html#setInputMap%28int, javax.swing.InputMap%29), setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, [add](../../java/awt/Container.html#add%28java.awt.Component, int%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object%29), [add](../../java/awt/Container.html#add%28java.awt.Component, java.lang.Object, int%29), [add](../../java/awt/Container.html#add%28java.lang.String, java.awt.Component%29), addContainerListener, addPropertyChangeListener, [addPropertyChangeListener](../../java/awt/Container.html#addPropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, [findComponentAt](../../java/awt/Container.html#findComponentAt%28int, int%29), findComponentAt, getComponent, [getComponentAt](../../java/awt/Container.html#getComponentAt%28int, int%29), getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, [list](../../java/awt/Container.html#list%28java.io.PrintStream, int%29), [list](../../java/awt/Container.html#list%28java.io.PrintWriter, int%29), [locate](../../java/awt/Container.html#locate%28int, int%29), minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, [setComponentZOrder](../../java/awt/Container.html#setComponentZOrder%28java.awt.Component, int%29), setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
[action](../../java/awt/Component.html#action%28java.awt.Event, java.lang.Object%29), add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, java.awt.image.ImageObserver%29), [checkImage](../../java/awt/Component.html#checkImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), [coalesceEvents](../../java/awt/Component.html#coalesceEvents%28java.awt.AWTEvent, java.awt.AWTEvent%29), contains, createImage, [createImage](../../java/awt/Component.html#createImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int%29), [createVolatileImage](../../java/awt/Component.html#createVolatileImage%28int, int, java.awt.ImageCapabilities%29), disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, byte, byte%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, double, double%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, float, float%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, long, long%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, java.lang.Object, java.lang.Object%29), [firePropertyChange](../../java/awt/Component.html#firePropertyChange%28java.lang.String, short, short%29), getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, 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](../../java/awt/Component.html#gotFocus%28java.awt.Event, java.lang.Object%29), handleEvent, hasFocus, hide, [imageUpdate](../../java/awt/Component.html#imageUpdate%28java.awt.Image, int, int, int, int, int%29), [inside](../../java/awt/Component.html#inside%28int, int%29), isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, [keyDown](../../java/awt/Component.html#keyDown%28java.awt.Event, int%29), [keyUp](../../java/awt/Component.html#keyUp%28java.awt.Event, int%29), list, list, list, location, [lostFocus](../../java/awt/Component.html#lostFocus%28java.awt.Event, java.lang.Object%29), [mouseDown](../../java/awt/Component.html#mouseDown%28java.awt.Event, int, int%29), [mouseDrag](../../java/awt/Component.html#mouseDrag%28java.awt.Event, int, int%29), [mouseEnter](../../java/awt/Component.html#mouseEnter%28java.awt.Event, int, int%29), [mouseExit](../../java/awt/Component.html#mouseExit%28java.awt.Event, int, int%29), [mouseMove](../../java/awt/Component.html#mouseMove%28java.awt.Event, int, int%29), [mouseUp](../../java/awt/Component.html#mouseUp%28java.awt.Event, int, int%29), [move](../../java/awt/Component.html#move%28int, int%29), nextFocus, paintAll, postEvent, [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, java.awt.image.ImageObserver%29), [prepareImage](../../java/awt/Component.html#prepareImage%28java.awt.Image, int, int, java.awt.image.ImageObserver%29), processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, [removePropertyChangeListener](../../java/awt/Component.html#removePropertyChangeListener%28java.lang.String, java.beans.PropertyChangeListener%29), repaint, [repaint](../../java/awt/Component.html#repaint%28int, int, int, int%29), repaint, resize, [resize](../../java/awt/Component.html#resize%28int, int%29), [setBounds](../../java/awt/Component.html#setBounds%28int, int, int, int%29), setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, [setLocation](../../java/awt/Component.html#setLocation%28int, int%29), setLocation, setName, setSize, [setSize](../../java/awt/Component.html#setSize%28int, int%29), show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../java/lang/Object.html#wait%28long, int%29) |
Field Detail |
---|
VERTICAL_SPLIT
public static final int VERTICAL_SPLIT
Vertical split indicates the Component
s are split along the y axis. For example the twoComponent
s will be split one on top of the other.
See Also:
HORIZONTAL_SPLIT
public static final int HORIZONTAL_SPLIT
Horizontal split indicates the Component
s are split along the x axis. For example the twoComponent
s will be split one to the left of the other.
See Also:
LEFT
public static final String LEFT
Used to add a Component
to the left of the otherComponent
.
See Also:
RIGHT
public static final String RIGHT
Used to add a Component
to the right of the otherComponent
.
See Also:
TOP
public static final String TOP
Used to add a Component
above the otherComponent
.
See Also:
BOTTOM
public static final String BOTTOM
Used to add a Component
below the otherComponent
.
See Also:
DIVIDER
public static final String DIVIDER
Used to add a Component
that will represent the divider.
See Also:
ORIENTATION_PROPERTY
public static final String ORIENTATION_PROPERTY
Bound property name for orientation (horizontal or vertical).
See Also:
CONTINUOUS_LAYOUT_PROPERTY
public static final String CONTINUOUS_LAYOUT_PROPERTY
Bound property name for continuousLayout.
See Also:
DIVIDER_SIZE_PROPERTY
public static final String DIVIDER_SIZE_PROPERTY
Bound property name for border.
See Also:
ONE_TOUCH_EXPANDABLE_PROPERTY
public static final String ONE_TOUCH_EXPANDABLE_PROPERTY
Bound property for oneTouchExpandable.
See Also:
LAST_DIVIDER_LOCATION_PROPERTY
public static final String LAST_DIVIDER_LOCATION_PROPERTY
Bound property for lastLocation.
See Also:
DIVIDER_LOCATION_PROPERTY
public static final String DIVIDER_LOCATION_PROPERTY
Bound property for the dividerLocation.
Since:
1.3
See Also:
RESIZE_WEIGHT_PROPERTY
public static final String RESIZE_WEIGHT_PROPERTY
Bound property for weight.
Since:
1.3
See Also:
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()
Creates a new JSplitPane
configured to arrange the child components side-by-side horizontally with no continuous layout, using two buttons for the components.
JSplitPane
public JSplitPane(int newOrientation)
Creates a new JSplitPane
configured with the specified orientation and no continuous layout.
Parameters:
newOrientation
- JSplitPane.HORIZONTAL_SPLIT
orJSplitPane.VERTICAL_SPLIT
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
JSplitPane
public JSplitPane(int newOrientation, boolean newContinuousLayout)
Creates a new JSplitPane
with the specified orientation and redrawing style.
Parameters:
newOrientation
- JSplitPane.HORIZONTAL_SPLIT
orJSplitPane.VERTICAL_SPLIT
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
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
JSplitPane
public JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane
with the specified orientation and with the specified components that do not do continuous redrawing.
Parameters:
newOrientation
- JSplitPane.HORIZONTAL_SPLIT
orJSplitPane.VERTICAL_SPLIT
newLeftComponent
- the Component
that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane
newRightComponent
- the Component
that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if orientation
is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT
JSplitPane
public JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
Creates a new JSplitPane
with the specified orientation and redrawing style, and with the specified components.
Parameters:
newOrientation
- JSplitPane.HORIZONTAL_SPLIT
orJSplitPane.VERTICAL_SPLIT
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
newRightComponent
- the Component
that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
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](../../javax/swing/JComponent.html#updateUI%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
See Also:
getUIClassID
public String getUIClassID()
Returns the name of the L&F class that renders this component.
Overrides:
[getUIClassID](../../javax/swing/JComponent.html#getUIClassID%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
the string "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 integer giving the size of the divider in pixels
getDividerSize
public int getDividerSize()
Returns the size of the divider.
Returns:
an integer 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)
Sets the value of the oneTouchExpandable
property, which must be true
for theJSplitPane
to provide a UI widget on the divider to quickly expand/collapse the divider. The default value of this property is false
. Some look and feels might not support one-touch expanding; they will ignore this property.
Parameters:
newValue
- true
to specify that the split pane should provide a collapse/expand widget
See Also:
isOneTouchExpandable
public boolean isOneTouchExpandable()
Gets the oneTouchExpandable
property.
Returns:
the value of the oneTouchExpandable
property
See Also:
setOneTouchExpandable(boolean)
setLastDividerLocation
public void setLastDividerLocation(int newLastLocation)
Sets the last location the divider was at tonewLastLocation
.
Parameters:
newLastLocation
- an integer 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 integer 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:
- JSplitPane.VERTICAL_SPLIT (above/below orientation of components)
- JSplitPane.HORIZONTAL_SPLIT (left/right orientation of components)
Parameters:
orientation
- an integer specifying the orientation
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if orientation is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT.
getOrientation
public int getOrientation()
Returns the orientation.
Returns:
an integer giving the orientation
See Also:
setContinuousLayout
public void setContinuousLayout(boolean newContinuousLayout)
Sets the value of the continuousLayout
property, which must be true
for the child components to be continuously redisplayed and laid out during user intervention. The default value of this property is false
. Some look and feels might not support continuous layout; they will ignore this property.
Parameters:
newContinuousLayout
- true
if the components should continuously be redrawn as the divider changes position
See Also:
isContinuousLayout
public boolean isContinuousLayout()
Gets the continuousLayout
property.
Returns:
the value of the continuousLayout
property
See Also:
setResizeWeight
public void setResizeWeight(double value)
Specifies how to distribute extra space when the size of the split pane changes. A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). Specifically, the left/top component gets (weight * diff) extra space and the right/bottom component gets (1 - weight) * diff extra space.
Parameters:
value
- as described above
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if value
is < 0 or > 1
Since:
1.3
getResizeWeight
public double getResizeWeight()
Returns the number that determines how extra space is distributed.
Returns:
how extra space is to be distributed on a resize of the split pane
Since:
1.3
resetToPreferredSizes
public void resetToPreferredSizes()
Lays out the JSplitPane
layout based on the preferred size of the children components. This will likely result in changing the divider location.
setDividerLocation
public void setDividerLocation(double proportionalLocation)
Sets the divider location as a percentage of theJSplitPane
's size.
This method is implemented in terms ofsetDividerLocation(int)
. This method immediately changes the size of the split pane based on its current size. If the split pane is not correctly realized and on screen, this method will have no effect (new divider location will become (current size * proportionalLocation) which is 0).
Parameters:
proportionalLocation
- a double-precision floating point value that specifies a percentage, from zero (top/left) to 1.0 (bottom/right)
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- 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, and then listeners are notified. A value less than 0 implies the divider should be reset to a value that attempts to honor the preferred size of the left/top component. After notifying the listeners, the last divider location is updated, via setLastDividerLocation
.
Parameters:
location
- an int specifying a UI-specific value (typically a pixel count)
getDividerLocation
public int getDividerLocation()
Returns the last value passed to setDividerLocation
. The value returned from this method may differ from the actual divider location (if setDividerLocation
was passed a value bigger than the curent size).
Returns:
an integer specifying the location of the divider
getMinimumDividerLocation
public int getMinimumDividerLocation()
Returns the minimum location of the divider from the look and feel implementation.
Returns:
an integer specifying a UI-specific value for the minimum location (typically a pixel count); or -1 if the UI isnull
getMaximumDividerLocation
public int getMaximumDividerLocation()
Returns the maximum location of the divider from the look and feel implementation.
Returns:
an integer specifying a UI-specific value for the maximum location (typically a pixel count); or -1 if the UI isnull
remove
public void remove(Component component)
Removes the child component, component
from the pane. Resets the leftComponent
orrightComponent
instance variable, as necessary.
Overrides:
[remove](../../java/awt/Container.html#remove%28java.awt.Component%29)
in class [Container](../../java/awt/Container.html "class in java.awt")
Parameters:
component
- the Component
to remove
See Also:
Container.add(java.awt.Component), Container.validate(), Container.remove(int)
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](../../java/awt/Container.html#remove%28int%29)
in class [Container](../../java/awt/Container.html "class in java.awt")
Parameters:
index
- an integer specifying the component to remove, where 1 specifies the left/top component and 2 specifies the bottom/right component
See Also:
Container.add(java.awt.Component), Container.validate(), Container.getComponentCount()
removeAll
public void removeAll()
Removes all the child components from the split pane. Resets theleftComonent
and rightComponent
instance variables.
Overrides:
[removeAll](../../java/awt/Container.html#removeAll%28%29)
in class [Container](../../java/awt/Container.html "class in java.awt")
See Also:
Container.add(java.awt.Component), Container.remove(int)
isValidateRoot
public boolean isValidateRoot()
Returns true, so that 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](../../javax/swing/JComponent.html#isValidateRoot%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
true
See Also:
addImpl
protected void addImpl(Component comp, Object constraints, int index)
Adds the specified component to this split pane. 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 identifiers the layout manager may throw anIllegalArgumentException
.
The possible constraints objects (Strings) are:
- JSplitPane.TOP
- JSplitPane.LEFT
- JSplitPane.BOTTOM
- JSplitPane.RIGHT
If the
constraints
object isnull
, the component is added in the first available position (left/top if open, else right/bottom).
Overrides:
[addImpl](../../java/awt/Container.html#addImpl%28java.awt.Component, java.lang.Object, int%29)
in class [Container](../../java/awt/Container.html "class in java.awt")
Parameters:
comp
- the component to add
constraints
- an Object
specifying the layout constraints (position) for this component
index
- an integer specifying the index in the container's list.
Throws:
[IllegalArgumentException](../../java/lang/IllegalArgumentException.html "class in java.lang")
- if the constraints
object does not match an existing component
See Also:
[Container.addImpl(Component, Object, int)](../../java/awt/Container.html#addImpl%28java.awt.Component, java.lang.Object, int%29)
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](../../javax/swing/JComponent.html#paintChildren%28java.awt.Graphics%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Parameters:
g
- the Graphics
context within which to paint
See Also:
JComponent.paint(java.awt.Graphics), Container.paint(java.awt.Graphics)
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](../../javax/swing/JComponent.html#paramString%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
a string representation of this JSplitPane
.
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JSplitPane. For split panes, the AccessibleContext takes the form of an AccessibleJSplitPane. A new AccessibleJSplitPane instance is created if necessary.
Specified by:
[getAccessibleContext](../../javax/accessibility/Accessible.html#getAccessibleContext%28%29)
in interface [Accessible](../../javax/accessibility/Accessible.html "interface in javax.accessibility")
Overrides:
[getAccessibleContext](../../javax/swing/JComponent.html#getAccessibleContext%28%29)
in class [JComponent](../../javax/swing/JComponent.html "class in javax.swing")
Returns:
an AccessibleJSplitPane that serves as the AccessibleContext of this JSplitPane
Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.