JavaTM Platform
Standard Ed. 6

javax.swing
类 JSplitPane

java.lang.Object
  继承者 java.awt.Component
      继承者 java.awt.Container
          继承者 javax.swing.JComponent
              继承者 javax.swing.JSplitPane
所有已实现的接口:
ImageObserver, MenuContainer, Serializable, Accessible

public class JSplitPane
     
extends JComponent
implements Accessible

JSplitPane 用于分隔两个(只能两个)Component。两个 Component 图形化分隔以外观实现为基础,并且这两个 Component 可以由用户交互式调整大小。有关如何使用 JSplitPane 的信息,请参阅 The Java Tutorial 中的 How to Use Split Panes 一节。

使用 JSplitPane.HORIZONTAL_SPLIT 可让分隔窗格中的两个 Component 从左到右排列,或者使用 JSplitPane.VERTICAL_SPLIT 使其从上到下排列。改变 Component 大小的首选方式是调用 setDividerLocation,其中 location 是新的 x 或 y 位置,具体取决于 JSplitPane 的方向。

要将 Component 调整到其首选大小,可调用 resetToPreferredSizes

当用户调整 Component 的大小时,Component 的最小大小用于确定 Component 能够设置的最大/最小位置。如果两个组件的最小大小大于分隔窗格的大小,则分隔条将不允许您调整其大小。改变 JComponent 最小大小,请参阅 JComponent.setMinimumSize(java.awt.Dimension)

当用户调整分隔窗格大小时,新的空间以 resizeWeight 为基础在两个组件之间分配。默认情况下,值为 0 表示右边/底部的组件获得所有空间,而值为 1 表示左边/顶部的组件获得所有空间。

警告:Swing 不是线程安全的。有关更多信息,请参阅 Swing's Threading Policy

警告:此类的序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
setDividerLocation(double), resetToPreferredSizes()

嵌套类摘要
protected  class JSplitPane.AccessibleJSplitPane
          此类实现 JSplitPane 类的可访问性支持。
 
从类 javax.swing.JComponent 继承的嵌套类/接口
JComponent.AccessibleJComponent
 
从类 java.awt.Container 继承的嵌套类/接口
Container.AccessibleAWTContainer
 
从类 java.awt.Component 继承的嵌套类/接口
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
字段摘要
static String BOTTOM
          用于添加一个 Component 到另一个 Component 的下面。
static String CONTINUOUS_LAYOUT_PROPERTY
          绑定 continuousLayout 属性名称。
protected  boolean continuousLayout
          当调整大小时视图是否连续重新显示。
static String DIVIDER
          用于添加一个表示分隔条的 Component
static String DIVIDER_LOCATION_PROPERTY
          绑定 dividerLocation 属性。
static String DIVIDER_SIZE_PROPERTY
          绑定 border 属性名称。
protected  int dividerSize
          分隔条大小。
static int HORIZONTAL_SPLIT
          水平分割表示 Component 沿 x 轴分割。
static String LAST_DIVIDER_LOCATION_PROPERTY
          绑定 lastLocation 属性。
protected  int lastDividerLocation
          分隔窗格的上一个位置。
static String LEFT
          用于添加一个 Component 到另一个 Component 的左边。
protected  Component leftComponent
          左边或者顶部的组件。
static String ONE_TOUCH_EXPANDABLE_PROPERTY
          绑定 oneTouchExpandable 属性。
protected  boolean oneTouchExpandable
          是否要提供一个小部件来快速展开/折叠分隔窗格。
protected  int orientation
          如何分割视图。
static String ORIENTATION_PROPERTY
          绑定 orientation(水平或者垂直)属性名称。
static String RESIZE_WEIGHT_PROPERTY
          绑定 weight 属性。
static String RIGHT
          用于添加一个 Component 到另一个 Component 的右边。
protected  Component rightComponent
          右边或者底部的组件。
static String TOP
          用于添加一个 Component 到另一个 Component 的上面。
static int VERTICAL_SPLIT
          垂直分割表示 Component 沿 y 轴分割。
 
从类 javax.swing.JComponent 继承的字段
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
从类 java.awt.Component 继承的字段
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
从接口 java.awt.image.ImageObserver 继承的字段
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
构造方法摘要
JSplitPane()
          创建一个配置为将其子组件水平排列、无连续布局、为组件使用两个按钮的新 JSplitPane
JSplitPane(int newOrientation)
          创建一个配置为指定方向且无连续布局的新 JSplitPane
JSplitPane(int newOrientation, boolean newContinuousLayout)
          创建一个具有指定方向和重绘方式的新 JSplitPane
JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)
          创建一个具有指定方向、重绘方式和指定组件的新 JSplitPane
JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)
          创建一个具有指定方向和不连续重绘的指定组件的新 JSplitPane
 
方法摘要
protected  void addImpl(Component comp, Object constraints, int index)
          将指定组件添加到此分隔窗格。
 AccessibleContext getAccessibleContext()
          获取与 JSplitPane 关联的 AccessibleContext。
 Component getBottomComponent()
          返回分隔条下面或者右边的组件。
 int getDividerLocation()
          返回最后传递给 setDividerLocation 的值。
 int getDividerSize()
          返回分隔条的大小。
 int getLastDividerLocation()
          返回分隔条所处的最后位置。
 Component getLeftComponent()
          返回分隔条左边(或者上面)的组件。
 int getMaximumDividerLocation()
          返回外观实现中分隔条的最大位置。
 int getMinimumDividerLocation()
          返回外观实现中分隔条的最小位置。
 int getOrientation()
          返回方向。
 double getResizeWeight()
          返回确定额外空间如何分配的数。
 Component getRightComponent()
          返回分隔条右边(或者下面)的组件。
 Component getTopComponent()
          返回分隔条上面或者左边的组件。
 SplitPaneUI getUI()
          返回提供当前外观的 SplitPaneUI
 String getUIClassID()
          返回呈现此组件的 L&F 类名。
 boolean isContinuousLayout()
          获取 continuousLayout 属性。
 boolean isOneTouchExpandable()
          获取 oneTouchExpandable 属性。
 boolean isValidateRoot()
          如果返回 true,则在此 JSplitPane 的任何后代上调用 revalidate,将导致在队列中加入一个验证 JSplitPane 及其所有后代的一个请求。
protected  void paintChildren(Graphics g)
          通知超类后,UI 通过 finishedPaintingChildren 通知子类,同时绘制边框。
protected  String paramString()
          返回此 JSplitPane 的字符串表示形式。
 void remove(Component component)
          移除窗格中的子组件 component
 void remove(int index)
          移除指定索引处的 Component
 void removeAll()
          从分隔窗格中移除所有子组件。
 void resetToPreferredSizes()
          以子组件的首选大小为基础调整 JSplitPane 的布局。
 void setBottomComponent(Component comp)
          将组件设置到分隔条的下面或者右边。
 void setContinuousLayout(boolean newContinuousLayout)
          设置 continuousLayout 属性的值,在用户干预期要使子组件连续地重新显示和布局子组件,此值必须为 true
 void setDividerLocation(double proportionalLocation)
          设置分隔条的位置为 JSplitPane 大小的一个百分比。
 void setDividerLocation(int location)
          设置分隔条的位置。
 void setDividerSize(int newSize)
          设置分隔条的大小。
 void setLastDividerLocation(int newLastLocation)
          将分隔条所处的最后位置设置为 newLastLocation
 void setLeftComponent(Component comp)
          将组件设置到分隔条的左边(或上面)。
 void setOneTouchExpandable(boolean newValue)
          设置 oneTouchExpandable 属性的值,要使 JSplitPane 在分隔条上提供一个 UI 小部件来快速展开/折叠分隔条,此属性必须为 true
 void setOrientation(int orientation)
          设置方向,或者分隔窗格的方式。
 void setResizeWeight(double value)
          指定当分隔窗格的大小改变时如何分配额外空间。
 void setRightComponent(Component comp)
          将组件设置到分隔条的右边(或者下面)。
 void setTopComponent(Component comp)
          将组件设置到分隔条的上面或者左边。
 void setUI(SplitPaneUI ui)
          设置呈现此组件的 L&F 对象。
 void updateUI()
          UIManager 发出的关于 L&F 已改变的通知。
 
从类 javax.swing.JComponent 继承的方法
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, 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, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
从类 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, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
从类 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, 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, 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, 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, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

VERTICAL_SPLIT

public static final int VERTICAL_SPLIT
垂直分割表示 Component 沿 y 轴分割。例如,两个 Component 将被分割成一个在另一个顶上。

另请参见:
常量字段值

HORIZONTAL_SPLIT

public static final int HORIZONTAL_SPLIT
水平分割表示 Component 沿 x 轴分割。例如,两个 Component 将被分割成一个在另一个左边。

另请参见:
常量字段值

LEFT

public static final String LEFT
用于添加一个 Component 到另一个 Component 的左边。

另请参见:
常量字段值

RIGHT

public static final String RIGHT
用于添加一个 Component 到另一个 Component 的右边。

另请参见:
常量字段值

TOP

public static final String TOP
用于添加一个 Component 到另一个 Component 的上面。

另请参见:
常量字段值

BOTTOM

public static final String BOTTOM
用于添加一个 Component 到另一个 Component 的下面。

另请参见:
常量字段值

DIVIDER

public static final String DIVIDER
用于添加一个表示分隔条的 Component

另请参见:
常量字段值

ORIENTATION_PROPERTY

public static final String ORIENTATION_PROPERTY
绑定 orientation(水平或者垂直)属性名称。

另请参见:
常量字段值

CONTINUOUS_LAYOUT_PROPERTY

public static final String CONTINUOUS_LAYOUT_PROPERTY
绑定 continuousLayout 属性名称。

另请参见:
常量字段值

DIVIDER_SIZE_PROPERTY

public static final String DIVIDER_SIZE_PROPERTY
绑定 border 属性名称。

另请参见:
常量字段值

ONE_TOUCH_EXPANDABLE_PROPERTY

public static final String ONE_TOUCH_EXPANDABLE_PROPERTY
绑定 oneTouchExpandable 属性。

另请参见:
常量字段值

LAST_DIVIDER_LOCATION_PROPERTY

public static final String LAST_DIVIDER_LOCATION_PROPERTY
绑定 lastLocation 属性。

另请参见:
常量字段值

DIVIDER_LOCATION_PROPERTY

public static final String DIVIDER_LOCATION_PROPERTY
绑定 dividerLocation 属性。

从以下版本开始:
1.3
另请参见:
常量字段值

RESIZE_WEIGHT_PROPERTY

public static final String RESIZE_WEIGHT_PROPERTY
绑定 weight 属性。

从以下版本开始:
1.3
另请参见:
常量字段值

orientation

protected int orientation
如何分割视图。


continuousLayout

protected boolean continuousLayout
当调整大小时视图是否连续重新显示。


leftComponent

protected Component leftComponent
左边或者顶部的组件。


rightComponent

protected Component rightComponent
右边或者底部的组件。


dividerSize

protected int dividerSize
分隔条大小。


oneTouchExpandable

protected boolean oneTouchExpandable
是否要提供一个小部件来快速展开/折叠分隔窗格。


lastDividerLocation

protected int lastDividerLocation
分隔窗格的上一个位置。

构造方法详细信息

JSplitPane

public JSplitPane()
创建一个配置为将其子组件水平排列、无连续布局、为组件使用两个按钮的新 JSplitPane


JSplitPane

public JSplitPane(int newOrientation)
创建一个配置为指定方向且无连续布局的新 JSplitPane

参数:
newOrientation - JSplitPane.HORIZONTAL_SPLITJSplitPane.VERTICAL_SPLIT
抛出:
IllegalArgumentException - 如果 orientation 不是 HORIZONTAL_SPLIT 或 VERTICAL_SPLIT 之一。

JSplitPane

public JSplitPane(int newOrientation,
                  boolean newContinuousLayout)
创建一个具有指定方向和重绘方式的新 JSplitPane

参数:
newOrientation - JSplitPane.HORIZONTAL_SPLITJSplitPane.VERTICAL_SPLIT
newContinuousLayout - 一个 boolean 值,当分隔条改变位置时组件连续重绘则为 true;当分隔条位置停止改变时才重绘则为 false
抛出:
IllegalArgumentException - 如果 orientation 不是 HORIZONTAL_SPLIT 或 VERTICAL_SPLIT 之一

JSplitPane

public JSplitPane(int newOrientation,
                  Component newLeftComponent,
                  Component newRightComponent)
创建一个具有指定方向和不连续重绘的指定组件的新 JSplitPane

参数:
newOrientation - JSplitPane.HORIZONTAL_SPLITJSplitPane.VERTICAL_SPLIT
newLeftComponent - 将出现在水平分隔窗格的左边或者垂直分隔窗格的顶部的 Component
newRightComponent - 将出现在水平分隔窗格的右边或者垂直分隔窗格的底部的 Component
抛出:
IllegalArgumentException - 如果 orientation 不是 HORIZONTAL_SPLIT 或 VERTICAL_SPLIT 之一

JSplitPane

public JSplitPane(int newOrientation,
                  boolean newContinuousLayout,
                  Component newLeftComponent,
                  Component newRightComponent)
创建一个具有指定方向、重绘方式和指定组件的新 JSplitPane

参数:
newOrientation - JSplitPane.HORIZONTAL_SPLITJSplitPane.VERTICAL_SPLIT
newContinuousLayout - 一个 boolean 值,当分隔条改变位置时组件连续重绘则为 true;当分隔条位置停止改变时才重绘则为 false
newLeftComponent - 将出现在水平分隔窗格的左边或者垂直分隔窗格的顶部的 Component
newRightComponent - 将出现在水平分隔窗格的右边或者垂直分隔窗格的底部的 Component
抛出:
IllegalArgumentException - 如果 orientation 不是 HORIZONTAL_SPLIT 或 VERTICAL_SPLIT 之一
方法详细信息

setUI

public void setUI(SplitPaneUI ui)
设置呈现此组件的 L&F 对象。

参数:
ui - SplitPaneUI 的 L&F 对象
另请参见:
UIDefaults.getUI(javax.swing.JComponent)

getUI

public SplitPaneUI getUI()
返回提供当前外观的 SplitPaneUI

返回:
呈现此组件的 SplitPaneUI 对象

updateUI

public void updateUI()
UIManager 发出的关于 L&F 已改变的通知。用来自 UIManager 的最新版本 UI 对象替换当前的 UI 对象。

覆盖:
JComponent 中的 updateUI
另请参见:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
返回呈现此组件的 L&F 类名。

覆盖:
JComponent 中的 getUIClassID
返回:
字符串 "SplitPaneUI"
另请参见:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setDividerSize

public void setDividerSize(int newSize)
设置分隔条的大小。

参数:
newSize - 给定分隔条大小的一个整数,以像素为单位

getDividerSize

public int getDividerSize()
返回分隔条的大小。

返回:
给定分隔条大小的一个整数,以像素为单位

setLeftComponent

public void setLeftComponent(Component comp)
将组件设置到分隔条的左边(或上面)。

参数:
comp - 在该位置中显示的 Component

getLeftComponent

public Component getLeftComponent()
返回分隔条左边(或者上面)的组件。

返回:
在该位置中显示的 Component

setTopComponent

public void setTopComponent(Component comp)
将组件设置到分隔条的上面或者左边。

参数:
comp - 在该位置中显示的 Component

getTopComponent

public Component getTopComponent()
返回分隔条上面或者左边的组件。

返回:
在该位置中显示的 Component

setRightComponent

public void setRightComponent(Component comp)
将组件设置到分隔条的右边(或者下面)。

参数:
comp - 在该位置中显示的 Component

getRightComponent

public Component getRightComponent()
返回分隔条右边(或者下面)的组件。

返回:
在该位置中显示的 Component

setBottomComponent

public void setBottomComponent(Component comp)
将组件设置到分隔条的下面或者右边。

参数:
comp - 在该位置中显示的 Component

getBottomComponent

public Component getBottomComponent()
返回分隔条下面或者右边的组件。

返回:
在该位置中显示的 Component

setOneTouchExpandable

public void setOneTouchExpandable(boolean newValue)
设置 oneTouchExpandable 属性的值,要使 JSplitPane 在分隔条上提供一个 UI 小部件来快速展开/折叠分隔条,此属性必须为 true。此属性的默认值为 false。有些外观可能不支持一键展开;它们将忽略此属性。

参数:
newValue - 指定为 true,则分隔窗格应该提供一个折叠/展开的小部件
另请参见:
isOneTouchExpandable()

isOneTouchExpandable

public boolean isOneTouchExpandable()
获取 oneTouchExpandable 属性。

返回:
oneTouchExpandable 的值
另请参见:
setOneTouchExpandable(boolean)

setLastDividerLocation

public void setLastDividerLocation(int newLastLocation)
将分隔条所处的最后位置设置为 newLastLocation

参数:
newLastLocation - 指定分隔条最后位置从窗格的左边(或者上边)到分隔条的左边(或者上边)的一个整数,以像素为单位

getLastDividerLocation

public int getLastDividerLocation()
返回分隔条所处的最后位置。

返回:
指定分隔条最后位置从窗格的左边(或者上边)到分隔条的左边(或者上边)的一个整数,以像素为单位

setOrientation

public void setOrientation(int orientation)
设置方向,或者分隔窗格的方式。选项有:

参数:
orientation - 指定方向的一个整数
抛出:
IllegalArgumentException - 如果方向不是如下之一:HORIZONTAL_SPLIT 或 VERTICAL_SPLIT。

getOrientation

public int getOrientation()
返回方向。

返回:
给定方向的一个整数
另请参见:
setOrientation(int)

setContinuousLayout

public void setContinuousLayout(boolean newContinuousLayout)
设置 continuousLayout 属性的值,在用户干预期要使子组件连续地重新显示和布局子组件,此值必须为 true。此属性的默认值为 false。一些外观可能不支持连续布局;它们将忽略此属性。

参数:
newContinuousLayout - 如果分隔条改变位置时组件连续重绘,则为 true
另请参见:
isContinuousLayout()

isContinuousLayout

public boolean isContinuousLayout()
获取 continuousLayout 属性。

返回:
continuousLayout 属性的值
另请参见:
setContinuousLayout(boolean)

setResizeWeight

public void setResizeWeight(double value)
指定当分隔窗格的大小改变时如何分配额外空间。在默认情况下,值为 0 表示右边/底部的组件获得所有额外空间(左边/顶部的组件固定),而值为 1 表示左边/顶部的组件获得所有额外空间(右边/底部的组件固定)。特别地,左边/顶部的组件获得 (weight * diff) 额外空间,并且右边/底部的组件获得 (1 - weight) * diff 额外空间。

参数:
value - 如上所述
抛出:
IllegalArgumentException - 如果 value 小于 0 或者大于 1
从以下版本开始:
1.3

getResizeWeight

public double getResizeWeight()
返回确定额外空间如何分配的数。

返回:
在分隔窗格的一次大小调整中如何分配额外空间
从以下版本开始:
1.3

resetToPreferredSizes

public void resetToPreferredSizes()
以子组件的首选大小为基础调整 JSplitPane 的布局。这将可能导致分隔条位置的改变。


setDividerLocation

public void setDividerLocation(double proportionalLocation)
设置分隔条的位置为 JSplitPane 大小的一个百分比。

根据 setDividerLocation(int) 来实现此方法。此方法以分隔窗格的当前大小为基础迅速改变窗格的大小。如果分隔窗格没有正确地实现并且不显示在屏幕上,此方法将不产生任何影响(新的分隔条位置将成为 0(当前的 size * proportionalLocation ))。

参数:
proportionalLocation - 指示百分比的双精度浮点值,从 0 (top/left) 到 1.0 (bottom/right)
抛出:
IllegalArgumentException - 如果指定的位置为 < 0 or > 1.0

setDividerLocation

public void setDividerLocation(int location)
设置分隔条的位置。这将传递给外观实现,然后通知侦听器。一个值小于 0 意味着分隔条应该重设为试图遵守左边/顶部组件首选大小的一个值。通知侦听器之后,最后的分隔条位置通过 setLastDividerLocation 更新。

参数:
location - 指定特定于 UI 值的一个整数(通常以像素为单位)

getDividerLocation

public int getDividerLocation()
返回最后传递给 setDividerLocation 的值。此方法返回的值可能与实际的分隔条位置不同(如果传递给 setDividerLocation 的值大于当前大小)。

返回:
指定分隔条位置的一个整数

getMinimumDividerLocation

public int getMinimumDividerLocation()
返回外观实现中分隔条的最小位置。

返回:
一个整数,它指定最小位置的特定于 UI 的值(通常以像素为单位);如果 UI 为 null,则返回 -1

getMaximumDividerLocation

public int getMaximumDividerLocation()
返回外观实现中分隔条的最大位置。

返回:
指定最大位置的特定于 UI 值的一个整数(通常以像素为单位);如果 UI 为 null,则返回 -1

remove

public void remove(Component component)
移除窗格中的子组件 component。如果必要,可重设 leftComponentrightComponent 实例变量。

覆盖:
Container 中的 remove
参数:
component - 要移除的 Component
另请参见:
Container.add(java.awt.Component), Container.validate(), Container.remove(int)

remove

public void remove(int index)
移除指定索引处的 Component。如果必要,可更新 leftComponentrightComponent 实例变量,然后通知超类。

覆盖:
Container 中的 remove
参数:
index - 指定要移除的组件的一个整数,为 1 时指定左边/顶部的组件,为 2 指定底部/右边的组件
另请参见:
Container.add(java.awt.Component), Container.validate(), Container.getComponentCount()

removeAll

public void removeAll()
从分隔窗格中移除所有子组件。重设 leftComponentrightComponent 实例变量。

覆盖:
Container 中的 removeAll
另请参见:
Container.add(java.awt.Component), Container.remove(int)

isValidateRoot

public boolean isValidateRoot()
如果返回 true,则在此 JSplitPane 的任何后代上调用 revalidate,将导致在队列中加入一个验证 JSplitPane 及其所有后代的一个请求。

覆盖:
JComponent 中的 isValidateRoot
返回:
true
另请参见:
JComponent.revalidate()

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
将指定组件添加到此分隔窗格。如果 constraints 标识左边/顶部或者右边/底部的子组件,并且之前已添加了一个具有该标识符的组件,则该组件将被移除,然后 comp 将被添加到该位置。如果 constraints 不是已知的标识符之一,则布局管理器可能抛出一个 IllegalArgumentException

可能的约束对象(字符串)是:

如果 constraints 对象为 null,则组件将被添加到第一个可用位置(如果展开,则为左边/顶部;否则为右边/底部)。

覆盖:
Container 中的 addImpl
参数:
comp - 要添加的组件
constraints - 指定此组件布局约束(位置)的一个 Object
index - 指定容器列表中索引的一个整数。
抛出:
IllegalArgumentException - 如果 constraints 对象不匹配现有的组件
另请参见:
Container.addImpl(Component, Object, int)

paintChildren

protected void paintChildren(Graphics g)
通知超类后,UI 通过 finishedPaintingChildren 通知子类,同时绘制边框。

覆盖:
JComponent 中的 paintChildren
参数:
g - 在其中进行绘制的 Graphics 上下文
另请参见:
JComponent.paint(java.awt.Graphics), Container.paint(java.awt.Graphics)

paramString

protected String paramString()
返回此 JSplitPane 的字符串表示形式。此方法仅在进行调试的时候使用,对于各个实现,所返回字符串的内容和格式可能有所不同。返回的字符串可能为空,但不可能为 null

覆盖:
JComponent 中的 paramString
返回:
JSplitPane 的字符串表示形式。

getAccessibleContext

public AccessibleContext getAccessibleContext()
获取与 JSplitPane 关联的 AccessibleContext。对于分隔窗格,AccessibleContext 采用 AccessibleJSplitPane 的形式。必要时创建新的 AccessibleJSplitPane 实例。

指定者:
接口 Accessible 中的 getAccessibleContext
覆盖:
JComponent 中的 getAccessibleContext
返回:
一个 AccessibleJSplitPane,它充当此 JSplitPane 的 AccessibleContext

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策