APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JSeparator

extends JComponent
implements SwingConstants, Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible, javax.swing.SwingConstants
Known Direct Subclasses
javax.swing.JToolBar.Separator, javax.swing.JPopupMenu.Separator
Annotations
@JavaBean
defaultProperty:UI
description:A divider between menu items.
@SwingContainer:false
@SuppressWarnings:serial
Imports
java.beans.BeanProperty, .JavaBean, java.io.IOException, .ObjectOutputStream, .Serial, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, javax.swing.plaf.SeparatorUI

JSeparator provides a general purpose component for implementing divider lines - most commonly used as a divider between menu items that breaks them up into logical groupings. Instead of using JSeparator directly, you can use the JMenu or JPopupMenu addSeparator method to create and add a separator. JSeparators may also be used elsewhere in a GUI wherever a visual divider is useful.

For more information and examples see How to Use Menus, a section in The Java Tutorial.

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 JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Georges Saab, Jeff Shapiro
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JSeparator.AccessibleJSeparator

This class implements accessibility support for the JSeparator class.

Field Summary

Modifier and TypeField and Description
private int
private static final String
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JSeparator()

Creates a new horizontal separator.

public
JSeparator(int
an integer specifying SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
orientation
)

Creates a new separator with the specified horizontal or vertical orientation.

Method Summary

Modifier and TypeMethod and Description
private void
checkOrientation(int orientation)

public AccessibleContext

Returns:

an AccessibleJSeparator that serves as the AccessibleContext of this JSeparator
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JSeparator.

public int

Returns:

The value of the orientation property, one of the following constants defined in SwingConstants: VERTICAL, or HORIZONTAL.
getOrientation
()

Returns the orientation of this separator.

public SeparatorUI

Returns:

the SeparatorUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.

public String

Returns:

the string "SeparatorUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

protected String

Returns:

a string representation of this JSeparator
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JSeparator.

public void
setOrientation(int
either SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
orientation
)

Sets the orientation of the separator.

public void
setUI(SeparatorUI
the SeparatorUI L&F object
ui
)

Sets the L&F object that renders this component.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

orientationback to summary
private int orientation
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject

Constructor Detail

JSeparatorback to summary
public JSeparator()

Creates a new horizontal separator.

JSeparatorback to summary
public JSeparator(int orientation)

Creates a new separator with the specified horizontal or vertical orientation.

Parameters
orientation:int

an integer specifying SwingConstants.HORIZONTAL or SwingConstants.VERTICAL

Exceptions
IllegalArgumentException:
if orientation is neither SwingConstants.HORIZONTAL nor SwingConstants.VERTICAL

Method Detail

checkOrientationback to summary
private void checkOrientation(int orientation)
getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JSeparator. For separators, the AccessibleContext takes the form of an AccessibleJSeparator. A new AccessibleJSeparator instance is created if necessary.

Returns:AccessibleContext

an AccessibleJSeparator that serves as the AccessibleContext of this JSeparator

Annotations
@BeanProperty
bound:false
getOrientationback to summary
public int getOrientation()

Returns the orientation of this separator.

Returns:int

The value of the orientation property, one of the following constants defined in SwingConstants: VERTICAL, or HORIZONTAL.

See Also
SwingConstants, setOrientation
getUIback to summary
public SeparatorUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the L&F object that renders this component.

Returns:SeparatorUI

the SeparatorUI object that renders this component

getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

Returns:String

the string "SeparatorUI"

Annotations
@BeanProperty
bound:false
See Also
JComponent#getUIClassID, UIDefaults#getUI
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JSeparator. 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.

Returns:String

a string representation of this JSeparator

setOrientationback to summary
public void setOrientation(int orientation)

Sets the orientation of the separator. The default value of this property is HORIZONTAL.

Parameters
orientation:int

either SwingConstants.HORIZONTAL or SwingConstants.VERTICAL

Annotations
@BeanProperty
preferred:true
visualUpdate:true
enumerationValues:SwingConstants.HORIZONTAL, SwingConstants.VERTICAL
description:The orientation of the separator.
Exceptions
IllegalArgumentException:
if orientation is neither SwingConstants.HORIZONTAL nor SwingConstants.VERTICAL
See Also
SwingConstants, getOrientation
setUIback to summary
public void setUI(SeparatorUI ui)

Sets the L&F object that renders this component.

Parameters
ui:SeparatorUI

the SeparatorUI L&F object

Annotations
@BeanProperty
hidden:true
visualUpdate:true
description:The UI object that implements the Component\'s LookAndFeel.
See Also
UIDefaults#getUI
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property to a value from the current look and feel.

See Also
JComponent#updateUI
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.writeObject.

if an I/O error occurs

javax.swing back to summary

protected Class JSeparator.AccessibleJSeparator

extends AccessibleJComponent
Class Inheritance
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the JSeparator class. It provides an implementation of the Java Accessibility API appropriate to separator user-interface elements.

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 JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJSeparator()

Constructs an AccessibleJSeparator.

Method Summary

Modifier and TypeMethod and Description
public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetAccessibleStateSetgetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJSeparatorback to summary
protected AccessibleJSeparator()

Constructs an AccessibleJSeparator.

Method Detail

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object