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

public Class MetalToolBarUI

extends BasicToolBarUI
Class Inheritance
Imports
javax.swing.*, java.awt.Color, .Component, .Container, .Dimension, .Frame, .Graphics, .GraphicsEnvironment, .Insets, .Point, .Rectangle, java.awt.event.*, java.lang.ref.WeakReference, java.util.*, java.beans.PropertyChangeListener, javax.swing.event.*, javax.swing.border.*, javax.swing.plaf.*, javax.swing.plaf.basic.*

A Metal Look and Feel implementation of ToolBarUI. This implementation is a "combined" view/controller.
Author
Jeff Shapiro

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
protected class
MetalToolBarUI.MetalDockingListener

DockingListener for MetalToolBarUI.

protected class

Field Summary

Modifier and TypeField and Description
private static List<WeakReference<JComponent>>
components

An array of WeakReferences that point to JComponents.

protected ContainerListener
contListener

This protected field is implementation specific.

private JMenuBar
lastMenuBar

Last menubar the toolbar touched.

private static Border
protected PropertyChangeListener
rolloverListener

This protected field is implementation specific.

Inherited from javax.swing.plaf.basic.BasicToolBarUI:
constraintBeforeFloatingdockingBorderColordockingColordockingListenerdownKeydragWindowfloatingBorderColorfloatingColorfocusedCompIndexleftKeypropertyListenerrightKeytoolBartoolBarContListenertoolBarFocusListenerupKey

Constructor Summary

AccessConstructor and Description
public
MetalToolBarUI()

Constructs a MetalToolBarUI.

Method Summary

Modifier and TypeMethod and Description
protected ContainerListener

Returns:

an instance of a ContainerListener or null
createContainerListener
()

Creates a container listener that will be added to the JToolBar.

protected MouseInputListener
createDockingListener()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createDockingListener.

Returns an instance of MouseInputListener.

protected Border
createNonRolloverBorder()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createNonRolloverBorder.

Creates the non rollover border for toolbar components.

private Border
createNonRolloverToggleBorder()

Hides javax.swing.plaf.basic.BasicToolBarUI.createNonRolloverToggleBorder.

Creates a non rollover border for Toggle buttons in the toolbar.

protected Border
createRolloverBorder()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createRolloverBorder.

Creates a rollover border for toolbar components.

protected PropertyChangeListener

Returns:

an instance of a PropertyChangeListener or null
createRolloverListener
()

Creates a property change listener that will be added to the JToolBar.

public static ComponentUI

Returns:

an instance of MetalToolBarUI
createUI
(JComponent
a component
c
)

Hides javax.swing.plaf.basic.BasicToolBarUI.createUI.

Constructs an instance of MetalToolBarUI.

pack-priv static boolean
doesMenuBarBorderToolBar(JMenuBar c)

Returns true if the passed in JMenuBar is above a horizontal JToolBar.

pack-priv static synchronized Object
findRegisteredComponentOfType(JComponent from, Class<?> target)

Finds a previously registered component of class target that shares the JRootPane ancestor of from.

protected void
public void
installUI(JComponent c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.installUI.

Configures the specified component appropriately for the look and feel.

pack-priv static synchronized void
register(JComponent c)

Registers the specified component.

protected void
setBorderToNonRollover(Component c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.setBorderToNonRollover.

Sets the border of the component to have a non-rollover border which was created by the createNonRolloverBorder method.

protected void
setDragOffset(Point
the offset
p
)

Sets the offset of the mouse cursor inside the DragWindow.

private void
setLastMenuBar(JMenuBar lastMenuBar)

protected void
public void
uninstallUI(JComponent c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.uninstallUI.

Reverses configuration which was done on the specified component during installUI.

pack-priv static synchronized void
unregister(JComponent c)

Unregisters the specified component.

public void
update(Graphics
Graphics to paint to
g
,
JComponent
JComponent painting on
c
)

Overrides javax.swing.plaf.ComponentUI.update.

If necessary paints the background of the component, then invokes paint.

Inherited from javax.swing.plaf.basic.BasicToolBarUI:
canDockcreateDragWindowcreateFloatingFramecreateFloatingWindowcreateFrameListenercreatePropertyListenercreateToolBarContListenercreateToolBarFocusListenerdragTofloatAtgetDockingColorgetFloatingColorgetNonRolloverBordergetRolloverBorderinstallComponentsinstallDefaultsinstallKeyboardActionsinstallNonRolloverBordersinstallNormalBordersinstallRolloverBordersisFloatingisRolloverBordersnavigateFocusedComppaintDragWindowsetBorderToNormalsetBorderToRolloversetDockingColorsetFloatingsetFloatingColorsetFloatingLocationsetOrientationsetRolloverBordersuninstallComponentsuninstallDefaultsuninstallKeyboardActions

Field Detail

componentsback to summary
private static List<WeakReference<JComponent>> components

An array of WeakReferences that point to JComponents. This will contain instances of JToolBars and JMenuBars and is used to find JToolBars/JMenuBars that border each other.

contListenerback to summary
protected ContainerListener contListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead.

See Also
createContainerListener
lastMenuBarback to summary
private JMenuBar lastMenuBar

Last menubar the toolbar touched. This is only useful for ocean.

nonRolloverBorderback to summary
private static Border nonRolloverBorder

Hides javax.swing.plaf.basic.BasicToolBarUI.nonRolloverBorder.

rolloverListenerback to summary
protected PropertyChangeListener rolloverListener

This protected field is implementation specific. Do not access directly or override. Use the create method instead.

See Also
createRolloverListener

Constructor Detail

MetalToolBarUIback to summary
public MetalToolBarUI()

Constructs a MetalToolBarUI.

Method Detail

createContainerListenerback to summary
protected ContainerListener createContainerListener()

Creates a container listener that will be added to the JToolBar. If this method returns null then it will not be added to the toolbar.

Returns:ContainerListener

an instance of a ContainerListener or null

createDockingListenerback to summary
protected MouseInputListener createDockingListener()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createDockingListener.

Doc from javax.swing.plaf.basic.BasicToolBarUI.createDockingListener.

Returns an instance of MouseInputListener.

createNonRolloverBorderback to summary
protected Border createNonRolloverBorder()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createNonRolloverBorder.

Doc from javax.swing.plaf.basic.BasicToolBarUI.createNonRolloverBorder.

Creates the non rollover border for toolbar components. This border will be installed as the border for components added to the toolbar if rollover borders are not enabled.

Override this method to provide an alternate rollover border.

createNonRolloverToggleBorderback to summary
private Border createNonRolloverToggleBorder()

Hides javax.swing.plaf.basic.BasicToolBarUI.createNonRolloverToggleBorder.

Creates a non rollover border for Toggle buttons in the toolbar.

createRolloverBorderback to summary
protected Border createRolloverBorder()

Overrides javax.swing.plaf.basic.BasicToolBarUI.createRolloverBorder.

Doc from javax.swing.plaf.basic.BasicToolBarUI.createRolloverBorder.

Creates a rollover border for toolbar components. The rollover border will be installed if rollover borders are enabled.

Override this method to provide an alternate rollover border.

createRolloverListenerback to summary
protected PropertyChangeListener createRolloverListener()

Creates a property change listener that will be added to the JToolBar. If this method returns null then it will not be added to the toolbar.

Returns:PropertyChangeListener

an instance of a PropertyChangeListener or null

createUIback to summary
public static ComponentUI createUI(JComponent c)

Hides javax.swing.plaf.basic.BasicToolBarUI.createUI.

Constructs an instance of MetalToolBarUI.

Parameters
c:JComponent

a component

Returns:ComponentUI

an instance of MetalToolBarUI

doesMenuBarBorderToolBarback to summary
pack-priv static boolean doesMenuBarBorderToolBar(JMenuBar c)

Returns true if the passed in JMenuBar is above a horizontal JToolBar.

findRegisteredComponentOfTypeback to summary
pack-priv static synchronized Object findRegisteredComponentOfType(JComponent from, Class<?> target)

Finds a previously registered component of class target that shares the JRootPane ancestor of from.

installListenersback to summary
protected void installListeners()

Overrides javax.swing.plaf.basic.BasicToolBarUI.installListeners.

Doc from javax.swing.plaf.basic.BasicToolBarUI.installListeners.

Registers listeners.

installUIback to summary
public void installUI(JComponent c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.installUI.

Doc from javax.swing.plaf.ComponentUI.installUI.

Configures the specified component appropriately for the look and feel. This method is invoked when the ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:

  1. Install default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
  2. Install a LayoutManager on the component if necessary.
  3. Create/add any required sub-components to the component.
  4. Create/install event listeners on the component.
  5. Create/install a PropertyChangeListener on the component in order to detect and respond to component property changes appropriately.
  6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  7. Initialize any appropriate instance data.
registerback to summary
pack-priv static synchronized void register(JComponent c)

Registers the specified component.

setBorderToNonRolloverback to summary
protected void setBorderToNonRollover(Component c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.setBorderToNonRollover.

Doc from javax.swing.plaf.basic.BasicToolBarUI.setBorderToNonRollover.

Sets the border of the component to have a non-rollover border which was created by the createNonRolloverBorder method.

setDragOffsetback to summary
protected void setDragOffset(Point p)

Sets the offset of the mouse cursor inside the DragWindow.

Parameters
p:Point

the offset

setLastMenuBarback to summary
private void setLastMenuBar(JMenuBar lastMenuBar)
uninstallListenersback to summary
protected void uninstallListeners()

Overrides javax.swing.plaf.basic.BasicToolBarUI.uninstallListeners.

Doc from javax.swing.plaf.basic.BasicToolBarUI.uninstallListeners.

Unregisters listeners.

uninstallUIback to summary
public void uninstallUI(JComponent c)

Overrides javax.swing.plaf.basic.BasicToolBarUI.uninstallUI.

Doc from javax.swing.plaf.ComponentUI.uninstallUI.

Reverses configuration which was done on the specified component during installUI. This method is invoked when this UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI, being careful to leave the JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:

  1. Remove any UI-set borders from the component.
  2. Remove any UI-set layout managers on the component.
  3. Remove any UI-added sub-components from the component.
  4. Remove any UI-added event/property listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Nullify any allocated instance data objects to allow for GC.
unregisterback to summary
pack-priv static synchronized void unregister(JComponent c)

Unregisters the specified component.

updateback to summary
public void update(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.update.

If necessary paints the background of the component, then invokes paint.

Parameters
g:Graphics

Graphics to paint to

c:JComponent

JComponent painting on

Exceptions
NullPointerException:
if g or c is null
Since
1.5
See Also
javax.swing.plaf.ComponentUI#update, javax.swing.plaf.ComponentUI#paint
javax.swing.plaf.metal back to summary

protected Class MetalToolBarUI.MetalContainerListener

extends ToolBarContListener
Class Inheritance

No longer used. The class cannot be removed for compatibility reasons.

Constructor Summary

AccessConstructor and Description
protected
MetalContainerListener()

Constructs a MetalContainerListener.

Method Summary

Inherited from javax.swing.plaf.basic.BasicToolBarUI.ToolBarContListener:
componentAddedcomponentRemoved

Constructor Detail

MetalContainerListenerback to summary
protected MetalContainerListener()

Constructs a MetalContainerListener.

javax.swing.plaf.metal back to summary

protected Class MetalToolBarUI.MetalDockingListener

extends DockingListener
Class Inheritance

DockingListener for MetalToolBarUI.

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from javax.swing.plaf.basic.BasicToolBarUI.DockingListener:
isDraggingorigintoolBar

Constructor Summary

AccessConstructor and Description
public
MetalDockingListener(JToolBar
an instance of JToolBar
t
)

Constructs the MetalDockingListener.

Method Summary

Modifier and TypeMethod and Description
public void
mouseDragged(MouseEvent e)

Overrides javax.swing.plaf.basic.BasicToolBarUI.DockingListener.mouseDragged.

Implements java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged.

public void
mousePressed(MouseEvent e)

Overrides javax.swing.plaf.basic.BasicToolBarUI.DockingListener.mousePressed.

Implements java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

Inherited from javax.swing.plaf.basic.BasicToolBarUI.DockingListener:
mouseClickedmouseEnteredmouseExitedmouseMovedmouseReleased

Field Detail

pressedInBumpsback to summary
private boolean pressedInBumps

Constructor Detail

MetalDockingListenerback to summary
public MetalDockingListener(JToolBar t)

Constructs the MetalDockingListener.

Parameters
t:JToolBar

an instance of JToolBar

Method Detail

mouseDraggedback to summary
public void mouseDragged(MouseEvent e)

Overrides javax.swing.plaf.basic.BasicToolBarUI.DockingListener.mouseDragged.

Implements java.awt.event.MouseMotionListener.mouseDragged.

Doc from java.awt.event.MouseMotionListener.mouseDragged.

Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).

Due to platform-dependent Drag&Drop implementations, MOUSE_DRAGGED events may not be delivered during a native Drag&Drop operation.

mousePressedback to summary
public void mousePressed(MouseEvent e)

Overrides javax.swing.plaf.basic.BasicToolBarUI.DockingListener.mousePressed.

Implements java.awt.event.MouseListener.mousePressed.

Doc from java.awt.event.MouseListener.mousePressed.

Invoked when a mouse button has been pressed on a component.

javax.swing.plaf.metal back to summary

protected Class MetalToolBarUI.MetalRolloverListener

extends PropertyListener
Class Inheritance

No longer used. The class cannot be removed for compatibility reasons.

Constructor Summary

AccessConstructor and Description
protected
MetalRolloverListener()

Constructs a MetalRolloverListener.

Method Summary

Inherited from javax.swing.plaf.basic.BasicToolBarUI.PropertyListener:
propertyChange

Constructor Detail

MetalRolloverListenerback to summary
protected MetalRolloverListener()

Constructs a MetalRolloverListener.