java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JSeparator
- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
,SwingConstants
- 直接已知的子类:
-
JPopupMenu.Separator
,JToolBar.Separator
@JavaBean(defaultProperty="UI", description="A divider between menu items.") public class JSeparator extends JComponent implements SwingConstants, Accessible
JSeparator
提供了一个通用的组件,用于实现分隔线 - 最常用于菜单项之间的分隔符,将它们分成逻辑分组。您可以使用JMenu
或JPopupMenu
的addSeparator
方法来创建和添加分隔符,而不是直接使用JSeparator
。在GUI的其他地方也可以使用JSeparator
,以便在需要时提供视觉分隔符。
有关更多信息和示例,请参阅如何使用菜单,这是Java教程中的一个部分。
警告: Swing不是线程安全的。有关更多信息,请参阅Swing的线程策略。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans
包中。请参阅XMLEncoder
。
- 自:
- 1.2
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
该类为JSeparator
类实现了辅助功能支持。Nested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields declared in class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields declared in class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields declared in interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription获取与此JSeparator关联的AccessibleContext。int
返回此分隔符的方向。getUI()
返回渲染此组件的L&F对象。返回渲染此组件的L&F类的名称。protected String
返回此JSeparator
的字符串表示形式。void
setOrientation
(int orientation) 设置分隔符的方向。void
setUI
(SeparatorUI ui) 设置渲染此组件的L&F对象。void
updateUI()
将UI属性重置为当前外观的值。Methods declared in class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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
Methods declared in class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods declared in 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, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
JSeparator
public JSeparator()创建一个新的水平分隔符。 -
JSeparator
public JSeparator(int orientation) 创建具有指定水平或垂直方向的新分隔符。- 参数:
-
orientation
- 指定SwingConstants.HORIZONTAL
或SwingConstants.VERTICAL
的整数 - 抛出:
-
IllegalArgumentException
- 如果orientation
既不是SwingConstants.HORIZONTAL
也不是SwingConstants.VERTICAL
-
-
Method Details
-
getUI
返回渲染此组件的L&F对象。- 覆盖:
-
getUI
在类中JComponent
- 返回:
- 渲染此组件的SeparatorUI对象
-
setUI
@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(SeparatorUI ui) 设置渲染此组件的L&F对象。- 参数:
-
ui
- SeparatorUI L&F对象 - 参见:
-
updateUI
public void updateUI()将UI属性重置为当前外观的值。- 覆盖:
-
updateUI
在类中JComponent
- 参见:
-
getUIClassID
返回渲染此组件的L&F类的名称。- 覆盖:
-
getUIClassID
在类中JComponent
- 返回:
- 字符串"SeparatorUI"
- 参见:
-
getOrientation
public int getOrientation()返回此分隔符的方向。- 返回:
-
方向属性的值,定义在
SwingConstants
中的以下常量之一:VERTICAL
或HORIZONTAL
。 - 参见:
-
setOrientation
@BeanProperty(preferred=true, visualUpdate=true, enumerationValues={"SwingConstants.HORIZONTAL","SwingConstants.VERTICAL"}, description="The orientation of the separator.") public void setOrientation(int orientation) 设置分隔符的方向。此属性的默认值为HORIZONTAL。- 参数:
-
orientation
-SwingConstants.HORIZONTAL
或SwingConstants.VERTICAL
- 抛出:
-
IllegalArgumentException
- 如果orientation
既不是SwingConstants.HORIZONTAL
也不是SwingConstants.VERTICAL
- 参见:
-
paramString
返回此JSeparator
的字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能因实现而异。返回的字符串可能为空,但不能为null
。- 覆盖:
-
paramString
在类中JComponent
- 返回:
-
此
JSeparator
的字符串表示形式
-
getAccessibleContext
获取与此JSeparator关联的AccessibleContext。对于分隔符,AccessibleContext采用AccessibleJSeparator的形式。如有必要,将创建一个新的AccessibleJSeparator实例。- 指定者:
-
getAccessibleContext
在接口中Accessible
- 覆盖:
-
getAccessibleContext
在类中Component
- 返回:
- 作为此JSeparator的AccessibleContext的AccessibleJSeparator
-