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

public Class JToolBar

extends JComponent
implements SwingConstants, Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible, javax.swing.SwingConstants
Known Direct Subclasses
sun.swing.WindowsPlacesBar
Annotations
@JavaBean
defaultProperty:UI
description:A component which displays commonly used controls or Actions.
@SwingContainer
@SuppressWarnings:serial
Imports
java.awt.Component, .Container, .Dimension, .Graphics, .Insets, .LayoutManager, .LayoutManager2, java.beans.BeanProperty, .JavaBean, .PropertyChangeEvent, .PropertyChangeListener, java.io.IOException, .ObjectOutputStream, .Serial, .Serializable, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, .AccessibleState, .AccessibleStateSet, javax.swing.plaf.ToolBarUI, .UIResource

JToolBar provides a component that is useful for displaying commonly used Actions or controls. For examples and information on using tool bars see How to Use Tool Bars, a section in The Java Tutorial.

With most look and feels, the user can drag out a tool bar into a separate window (unless the floatable property is set to false). For drag-out to work correctly, it is recommended that you add JToolBar instances to one of the four "sides" of a container whose layout manager is a BorderLayout, and do not add children to any of the other four "sides".

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
See Also
Action

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JToolBar.AccessibleJToolBar

This class implements accessibility support for the JToolBar class.

private class
public static class
JToolBar.Separator

A toolbar-specific separator.

Field Summary

Modifier and TypeField and Description
private boolean
private Insets
private int
private boolean
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
JToolBar()

Creates a new tool bar; orientation defaults to HORIZONTAL.

public
JToolBar(int
the orientation desired
orientation
)

Creates a new tool bar with the specified orientation.

public
JToolBar(String
the name of the tool bar
name
)

Creates a new tool bar with the specified name.

public
JToolBar(String
the name of the tool bar
name
,
int
the initial orientation -- it must be either HORIZONTAL or VERTICAL
orientation
)

Creates a new tool bar with a specified name and orientation.

Method Summary

Modifier and TypeMethod and Description
public JButton

Returns:

the new button which dispatches the action
add
(Action
the Action object to add as a new menu item
a
)

Adds a new JButton which dispatches the action.

protected void
addImpl(Component
the component to be enhanced
comp
,
Object
the constraints to be enforced on the component
constraints
,
int
the index of the component
index
)

Overrides java.awt.Container.addImpl.

If a JButton is being added, it is initially set to be disabled.

public void
addSeparator()

Appends a separator of default size to the end of the tool bar.

public void
addSeparator(Dimension
the Dimension of the separator
size
)

Appends a separator of a specified size to the end of the tool bar.

private void
checkOrientation(int orientation)

protected PropertyChangeListener

Returns:

null
createActionChangeListener
(JButton
a JButton
b
)

Returns a properly configured PropertyChangeListener which updates the control as changes to the Action occur, or null if the default property change listener for the control is desired.

protected JButton

Returns:

the newly created button
createActionComponent
(Action
the Action for the button to be added
a
)

Factory method which creates the JButton for Actions added to the JToolBar.

public AccessibleContext

Returns:

an AccessibleJToolBar that serves as the AccessibleContext of this JToolBar
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JToolBar.

public Component

Returns:

the Component at that position, or null for an invalid index
getComponentAtIndex
(int
the component's position, where 0 is first
i
)

Returns the component at the specified index.

public int

Returns:

an integer indicating the component's position, where 0 is first
getComponentIndex
(Component
the Component to find
c
)

Returns the index of the specified component.

public Insets

Returns:

an Insets object containing the margin values
getMargin
()

Returns the margin between the tool bar's border and its buttons.

public int

Returns:

an integer representing the current orientation -- either HORIZONTAL or VERTICAL
getOrientation
()

Returns the current orientation of the tool bar.

public ToolBarUI

Returns:

the tool bar's current UI.
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the tool bar's current UI.

public String

Returns:

the string "ToolBarUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

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

public boolean

Returns:

the value of the borderPainted property
isBorderPainted
()

Gets the borderPainted property.

public boolean

Returns:

the value of the floatable property
isFloatable
()

Gets the floatable property.

public boolean

Returns:

true if rollover toolbar buttons are to be drawn; otherwise false
isRollover
()

Returns the rollover state.

protected void
paintBorder(Graphics
the Graphics context in which the painting is done
g
)

Overrides javax.swing.JComponent.paintBorder.

Paints the tool bar's border if the borderPainted property is true.

protected String

Returns:

a string representation of this JToolBar.
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JToolBar.

public void
setBorderPainted(boolean
if true, the border is painted
b
)

Sets the borderPainted property, which is true if the border should be painted.

public void
setFloatable(boolean
if true, the tool bar can be moved; false otherwise
b
)

Sets the floatable property, which must be true for the user to move the tool bar.

public void
setLayout(LayoutManager mgr)

Overrides java.awt.Container.setLayout.

Sets the layout manager for this container.

public void
setMargin(Insets
an Insets object that defines the space between the border and the buttons
m
)

Sets the margin between the tool bar's border and its buttons.

public void
setOrientation(int
the new orientation -- either HORIZONTAL or VERTICAL
o
)

Sets the orientation of the tool bar.

public void
setRollover(boolean
true for rollover toolbar buttons; otherwise false
rollover
)

Sets the rollover state of this toolbar.

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

Sets the L&F object that renders this component.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Notification from the UIFactory that the L&F has changed.

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:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

floatableback to summary
private boolean floatable
marginback to summary
private Insets margin
orientationback to summary
private int orientation
paintBorderback to summary
private boolean paintBorder
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject

Constructor Detail

JToolBarback to summary
public JToolBar()

Creates a new tool bar; orientation defaults to HORIZONTAL.

JToolBarback to summary
public JToolBar(int orientation)

Creates a new tool bar with the specified orientation. The orientation must be either HORIZONTAL or VERTICAL.

Parameters
orientation:int

the orientation desired

JToolBarback to summary
public JToolBar(String name)

Creates a new tool bar with the specified name. The name is used as the title of the undocked tool bar. The default orientation is HORIZONTAL.

Parameters
name:String

the name of the tool bar

Since
1.3
JToolBarback to summary
public JToolBar(String name, int orientation)

Creates a new tool bar with a specified name and orientation. All other constructors call this constructor. If orientation is an invalid value, an exception will be thrown.

Parameters
name:String

the name of the tool bar

orientation:int

the initial orientation -- it must be either HORIZONTAL or VERTICAL

Exceptions
IllegalArgumentException:
if orientation is neither HORIZONTAL nor VERTICAL
Since
1.3

Method Detail

addback to summary
public JButton add(Action a)

Adds a new JButton which dispatches the action.

Parameters
a:Action

the Action object to add as a new menu item

Returns:JButton

the new button which dispatches the action

addImplback to summary
protected void addImpl(Component comp, Object constraints, int index)

Overrides java.awt.Container.addImpl.

If a JButton is being added, it is initially set to be disabled.

Parameters
comp:Component

the component to be enhanced

constraints:Object

the constraints to be enforced on the component

index:int

the index of the component

addSeparatorback to summary
public void addSeparator()

Appends a separator of default size to the end of the tool bar. The default size is determined by the current look and feel.

addSeparatorback to summary
public void addSeparator(Dimension size)

Appends a separator of a specified size to the end of the tool bar.

Parameters
size:Dimension

the Dimension of the separator

checkOrientationback to summary
private void checkOrientation(int orientation)
createActionChangeListenerback to summary
protected PropertyChangeListener createActionChangeListener(JButton b)

Returns a properly configured PropertyChangeListener which updates the control as changes to the Action occur, or null if the default property change listener for the control is desired.

Parameters
b:JButton

a JButton

Returns:PropertyChangeListener

null

createActionComponentback to summary
protected JButton createActionComponent(Action a)

Factory method which creates the JButton for Actions added to the JToolBar. The default name is empty if a null action is passed.

Parameters
a:Action

the Action for the button to be added

Returns:JButton

the newly created button

Since
1.3
See Also
Action
getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JToolBar. For tool bars, the AccessibleContext takes the form of an AccessibleJToolBar. A new AccessibleJToolBar instance is created if necessary.

Returns:AccessibleContext

an AccessibleJToolBar that serves as the AccessibleContext of this JToolBar

Annotations
@BeanProperty
bound:false
getComponentAtIndexback to summary
public Component getComponentAtIndex(int i)

Returns the component at the specified index.

Parameters
i:int

the component's position, where 0 is first

Returns:Component

the Component at that position, or null for an invalid index

getComponentIndexback to summary
public int getComponentIndex(Component c)

Returns the index of the specified component. (Note: Separators occupy index positions.)

Parameters
c:Component

the Component to find

Returns:int

an integer indicating the component's position, where 0 is first

getMarginback to summary
public Insets getMargin()

Returns the margin between the tool bar's border and its buttons.

Returns:Insets

an Insets object containing the margin values

See Also
Insets
getOrientationback to summary
public int getOrientation()

Returns the current orientation of the tool bar. The value is either HORIZONTAL or VERTICAL.

Returns:int

an integer representing the current orientation -- either HORIZONTAL or VERTICAL

See Also
setOrientation
getUIback to summary
public ToolBarUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the tool bar's current UI.

Returns:ToolBarUI

the tool bar's current UI.

See Also
setUI
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 "ToolBarUI"

Annotations
@BeanProperty
bound:false
See Also
JComponent#getUIClassID, UIDefaults#getUI
isBorderPaintedback to summary
public boolean isBorderPainted()

Gets the borderPainted property.

Returns:boolean

the value of the borderPainted property

See Also
setBorderPainted
isFloatableback to summary
public boolean isFloatable()

Gets the floatable property.

Returns:boolean

the value of the floatable property

See Also
setFloatable
isRolloverback to summary
public boolean isRollover()

Returns the rollover state.

Returns:boolean

true if rollover toolbar buttons are to be drawn; otherwise false

Since
1.4
See Also
setRollover(boolean)
paintBorderback to summary
protected void paintBorder(Graphics g)

Overrides javax.swing.JComponent.paintBorder.

Paints the tool bar's border if the borderPainted property is true.

Parameters
g:Graphics

the Graphics context in which the painting is done

See Also
JComponent#paint, JComponent#setBorder
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

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

setBorderPaintedback to summary
public void setBorderPainted(boolean b)

Sets the borderPainted property, which is true if the border should be painted. The default value for this property is true. Some look and feels might not implement painted borders; they will ignore this property.

Parameters
b:boolean

if true, the border is painted

Annotations
@BeanProperty
expert:true
description:Does the tool bar paint its borders?
See Also
isBorderPainted
setFloatableback to summary
public void setFloatable(boolean b)

Sets the floatable property, which must be true for the user to move the tool bar. Typically, a floatable tool bar can be dragged into a different position within the same container or out into its own window. The default value of this property is true. Some look and feels might not implement floatable tool bars; they will ignore this property.

Parameters
b:boolean

if true, the tool bar can be moved; false otherwise

Annotations
@BeanProperty
preferred:true
description:Can the tool bar be made to float by the user?
See Also
isFloatable
setLayoutback to summary
public void setLayout(LayoutManager mgr)

Overrides java.awt.Container.setLayout.

Doc from java.awt.Container.setLayout.

Sets the layout manager for this container.

This method changes layout-related information, and therefore, invalidates the component hierarchy.

setMarginback to summary
public void setMargin(Insets m)

Sets the margin between the tool bar's border and its buttons. Setting to null causes the tool bar to use the default margins. The tool bar's default Border object uses this value to create the proper margin. However, if a non-default border is set on the tool bar, it is that Border object's responsibility to create the appropriate margin space (otherwise this property will effectively be ignored).

Parameters
m:Insets

an Insets object that defines the space between the border and the buttons

Annotations
@BeanProperty
expert:true
description:The margin between the tool bar\'s border and contents
See Also
Insets
setOrientationback to summary
public void setOrientation(int o)

Sets the orientation of the tool bar. The orientation must have either the value HORIZONTAL or VERTICAL. If orientation is an invalid value, an exception will be thrown.

Parameters
o:int

the new orientation -- either HORIZONTAL or VERTICAL

Annotations
@BeanProperty
preferred:true
enumerationValues:SwingConstants.HORIZONTAL, SwingConstants.VERTICAL
description:The current orientation of the tool bar
Exceptions
IllegalArgumentException:
if orientation is neither HORIZONTAL nor VERTICAL
See Also
getOrientation
setRolloverback to summary
public void setRollover(boolean rollover)

Sets the rollover state of this toolbar. If the rollover state is true then the border of the toolbar buttons will be drawn only when the mouse pointer hovers over them. The default value of this property is false.

The implementation of a look and feel may choose to ignore this property.

Parameters
rollover:boolean

true for rollover toolbar buttons; otherwise false

Annotations
@BeanProperty
preferred:true
visualUpdate:true
description:Will draw rollover button borders in the toolbar.
Since
1.4
setUIback to summary
public void setUI(ToolBarUI ui)

Sets the L&F object that renders this component.

Parameters
ui:ToolBarUI

the ToolBarUI 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.

Notification from the UIFactory that the L&F has changed. Called to replace the UI with the latest version from the UIFactory.

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 JToolBar.AccessibleJToolBar

extends AccessibleJComponent
Class Inheritance

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

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJToolBar()

Constructs an AccessibleJToolBar.

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.

public AccessibleStateSet

Returns:

an instance of AccessibleStateSet containing the current state set of the object
getAccessibleStateSet
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the state of this object.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJToolBarback to summary
protected AccessibleJToolBar()

Constructs an AccessibleJToolBar.

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

getAccessibleStateSetback to summary
public AccessibleStateSet getAccessibleStateSet()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the state of this object.

Returns:AccessibleStateSet

an instance of AccessibleStateSet containing the current state set of the object

See Also
AccessibleState
javax.swing back to summary

private Class JToolBar.DefaultToolBarLayout

extends Object
implements LayoutManager2, Serializable, PropertyChangeListener, UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource, java.beans.PropertyChangeListener, java.util.EventListener, java.io.Serializable, java.awt.LayoutManager2, java.awt.LayoutManager

Field Summary

Modifier and TypeField and Description
pack-priv BoxLayout

Constructor Summary

AccessConstructor and Description
pack-priv
DefaultToolBarLayout(int orientation)

Method Summary

Modifier and TypeMethod and Description
public void
addLayoutComponent(String name, Component comp)

Implements java.awt.LayoutManager.addLayoutComponent.

If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

public void
addLayoutComponent(Component comp, Object constraints)

Implements java.awt.LayoutManager2.addLayoutComponent.

Adds the specified component to the layout, using the specified constraint object.

public float
getLayoutAlignmentX(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentX.

Returns the alignment along the x axis.

public float
getLayoutAlignmentY(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentY.

Returns the alignment along the y axis.

public void
invalidateLayout(Container target)

Implements java.awt.LayoutManager2.invalidateLayout.

Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

public void
layoutContainer(Container target)

Implements java.awt.LayoutManager.layoutContainer.

Lays out the specified container.

public Dimension
maximumLayoutSize(Container target)

Implements java.awt.LayoutManager2.maximumLayoutSize.

Calculates the maximum size dimensions for the specified container, given the components it contains.

public Dimension
minimumLayoutSize(Container target)

Implements java.awt.LayoutManager.minimumLayoutSize.

Calculates the minimum size dimensions for the specified container, given the components it contains.

public Dimension
preferredLayoutSize(Container target)

Implements java.awt.LayoutManager.preferredLayoutSize.

Calculates the preferred size dimensions for the specified container, given the components it contains.

public void
propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

public void
removeLayoutComponent(Component comp)

Implements java.awt.LayoutManager.removeLayoutComponent.

Removes the specified component from the layout.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lmback to summary
pack-priv BoxLayout lm

Constructor Detail

DefaultToolBarLayoutback to summary
pack-priv DefaultToolBarLayout(int orientation)

Method Detail

addLayoutComponentback to summary
public void addLayoutComponent(String name, Component comp)

Implements java.awt.LayoutManager.addLayoutComponent.

Doc from java.awt.LayoutManager.addLayoutComponent.

If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

addLayoutComponentback to summary
public void addLayoutComponent(Component comp, Object constraints)

Implements java.awt.LayoutManager2.addLayoutComponent.

Doc from java.awt.LayoutManager2.addLayoutComponent.

Adds the specified component to the layout, using the specified constraint object.

getLayoutAlignmentXback to summary
public float getLayoutAlignmentX(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentX.

Doc from java.awt.LayoutManager2.getLayoutAlignmentX.

Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

getLayoutAlignmentYback to summary
public float getLayoutAlignmentY(Container target)

Implements java.awt.LayoutManager2.getLayoutAlignmentY.

Doc from java.awt.LayoutManager2.getLayoutAlignmentY.

Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

invalidateLayoutback to summary
public void invalidateLayout(Container target)

Implements java.awt.LayoutManager2.invalidateLayout.

Doc from java.awt.LayoutManager2.invalidateLayout.

Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

layoutContainerback to summary
public void layoutContainer(Container target)

Implements java.awt.LayoutManager.layoutContainer.

Doc from java.awt.LayoutManager.layoutContainer.

Lays out the specified container.

maximumLayoutSizeback to summary
public Dimension maximumLayoutSize(Container target)

Implements java.awt.LayoutManager2.maximumLayoutSize.

Doc from java.awt.LayoutManager2.maximumLayoutSize.

Calculates the maximum size dimensions for the specified container, given the components it contains.

minimumLayoutSizeback to summary
public Dimension minimumLayoutSize(Container target)

Implements java.awt.LayoutManager.minimumLayoutSize.

Doc from java.awt.LayoutManager.minimumLayoutSize.

Calculates the minimum size dimensions for the specified container, given the components it contains.

preferredLayoutSizeback to summary
public Dimension preferredLayoutSize(Container target)

Implements java.awt.LayoutManager.preferredLayoutSize.

Doc from java.awt.LayoutManager.preferredLayoutSize.

Calculates the preferred size dimensions for the specified container, given the components it contains.

propertyChangeback to summary
public void propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

removeLayoutComponentback to summary
public void removeLayoutComponent(Component comp)

Implements java.awt.LayoutManager.removeLayoutComponent.

Doc from java.awt.LayoutManager.removeLayoutComponent.

Removes the specified component from the layout.

javax.swing back to summary

public Class JToolBar.Separator

extends JSeparator
Class Inheritance

A toolbar-specific separator. An object with dimension but no contents used to divide buttons on a tool bar into groups.

Field Summary

Modifier and TypeField and Description
private Dimension

Constructor Summary

AccessConstructor and Description
public
Separator()

Creates a new toolbar separator with the default size as defined by the current look and feel.

public
Separator(Dimension
the Dimension of the separator
size
)

Creates a new toolbar separator with the specified size.

Method Summary

Modifier and TypeMethod and Description
public Dimension

Returns:

the Dimension object containing the separator's maximum size
getMaximumSize
()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size for the separator.

public Dimension

Returns:

the Dimension object containing the separator's minimum size
getMinimumSize
()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size for the separator.

public Dimension

Returns:

the Dimension object containing the separator's preferred size
getPreferredSize
()

Overrides javax.swing.JComponent.getPreferredSize.

Returns the preferred size for the separator.

public Dimension

Returns:

the Dimension object containing the separator's size (This is a reference, NOT a copy!)
getSeparatorSize
()

Returns the size of the separator

public String

Returns:

the string "ToolBarSeparatorUI"
getUIClassID
()

Overrides javax.swing.JSeparator.getUIClassID.

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

public void
setSeparatorSize(Dimension
the new Dimension of the separator
size
)

Sets the size of the separator.

Inherited from javax.swing.JSeparator:
getAccessibleContextgetOrientationgetUIparamStringsetOrientationsetUIupdateUI

Field Detail

separatorSizeback to summary
private Dimension separatorSize

Constructor Detail

Separatorback to summary
public Separator()

Creates a new toolbar separator with the default size as defined by the current look and feel.

Separatorback to summary
public Separator(Dimension size)

Creates a new toolbar separator with the specified size.

Parameters
size:Dimension

the Dimension of the separator

Method Detail

getMaximumSizeback to summary
public Dimension getMaximumSize()

Overrides javax.swing.JComponent.getMaximumSize.

Returns the maximum size for the separator.

Returns:Dimension

the Dimension object containing the separator's maximum size

getMinimumSizeback to summary
public Dimension getMinimumSize()

Overrides javax.swing.JComponent.getMinimumSize.

Returns the minimum size for the separator.

Returns:Dimension

the Dimension object containing the separator's minimum size

getPreferredSizeback to summary
public Dimension getPreferredSize()

Overrides javax.swing.JComponent.getPreferredSize.

Returns the preferred size for the separator.

Returns:Dimension

the Dimension object containing the separator's preferred size

getSeparatorSizeback to summary
public Dimension getSeparatorSize()

Returns the size of the separator

Returns:Dimension

the Dimension object containing the separator's size (This is a reference, NOT a copy!)

getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JSeparator.getUIClassID.

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

Returns:String

the string "ToolBarSeparatorUI"

See Also
JComponent#getUIClassID, UIDefaults#getUI
setSeparatorSizeback to summary
public void setSeparatorSize(Dimension size)

Sets the size of the separator.

Parameters
size:Dimension

the new Dimension of the separator