javax.swing.plaf.basic

Class BasicToolBarUI

Implemented Interfaces:
SwingConstants
Known Direct Subclasses:
MetalToolBarUI

public class BasicToolBarUI
extends ToolBarUI
implements SwingConstants

This is the Basic Look and Feel UI class for JToolBar.

Nested Class Summary

class
BasicToolBarUI.DockingListener
This is the MouseHandler class that allows the user to drag the JToolBar in and out of the parent and dock it if it can.
protected class
BasicToolBarUI.DragWindow
This is the window that appears when the JToolBar is being dragged around.
protected class
BasicToolBarUI.FrameListener
This helper class listens for Window events from the floatable window and if it is closed, returns the JToolBar to the last known good location.
protected class
BasicToolBarUI.PropertyListener
This helper class listens for PropertyChangeEvents from the JToolBar.
protected class
BasicToolBarUI.ToolBarContListener
This helper class listens for components added to and removed from the JToolBar.
protected class
BasicToolBarUI.ToolBarFocusListener
DOCUMENT ME!

Field Summary

protected String
constraintBeforeFloating
The last known BorderLayout constraint before floating.
protected Color
dockingBorderColor
The color of the border when it is dockable.
protected Color
dockingColor
The background color of the JToolBar when it is dockable.
protected MouseInputListener
dockingListener
The docking listener responsible for mouse events on the JToolBar.
protected KeyStroke
downKey
Deprecated. since JDK1.3.
protected BasicToolBarUI.DragWindow
dragWindow
The window used for dragging the JToolBar.
protected Color
floatingBorderColor
The color of the border when it is not dockable.
protected Color
floatingColor
The background color of the JToolBar when it is not dockable.
protected int
focusedCompIndex
The index of the focused component.
protected KeyStroke
leftKey
Deprecated. since JDK1.3.
protected PropertyChangeListener
propertyListener
The PropertyChangeListener for the JToolBar.
protected KeyStroke
rightKey
Deprecated. since JDK1.3.
protected JToolBar
toolBar
The JToolBar this UI delegate is responsible for.
protected ContainerListener
toolBarContListener
The Container listener for the JToolBar.
protected FocusListener
toolBarFocusListener
The Focus listener for the JToolBar.
protected KeyStroke
upKey
Deprecated. since JDK1.3.

Fields inherited from 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

BasicToolBarUI()
This method creates a new BasicToolBarUI object for the given JToolBar.

Method Summary

boolean
canDock(Component c, Point p)
This method returns whether the JToolBar can dock at the given position.
protected MouseInputListener
createDockingListener()
This method creates a new DockingListener for the JToolBar.
protected BasicToolBarUI.DragWindow
createDragWindow(JToolBar toolbar)
This method creates a new DragWindow for the given JToolBar.
protected JFrame
createFloatingFrame(JToolBar toolbar)
This method creates a new floating frame for the JToolBar.
protected RootPaneContainer
createFloatingWindow(JToolBar toolbar)
This method creates a new floating window for the JToolBar.
protected WindowListener
createFrameListener()
This method creates a new WindowListener for the JToolBar.
protected Border
createNonRolloverBorder()
This method creates a new nonRolloverBorder for JButtons when the JToolBar's rollover property is set to false.
protected PropertyChangeListener
createPropertyListener()
This method creates a new PropertyChangeListener for the JToolBar.
protected Border
createRolloverBorder()
This method creates a new rollover border for JButtons when the JToolBar's rollover property is set to true.
protected ContainerListener
createToolBarContListener()
This method creates a new Container listener for the JToolBar.
protected FocusListener
createToolBarFocusListener()
This method creates a new FocusListener for the JToolBar.
static ComponentUI
createUI(JComponent c)
This method creates a new UI delegate for the given JComponent.
protected void
dragTo(Point position, Point origin)
This method is called to drag the DragWindow around when the JToolBar is being dragged around.
protected void
floatAt(Point position, Point origin)
This method is used at the end of a drag session to place the frame in either its original parent as a docked JToolBar or in its floating frame.
Color
getDockingColor()
This method returns the docking color.
Color
getFloatingColor()
This method returns the Color which is displayed when over a floating area.
Dimension
getMaximumSize(JComponent c)
This method returns the maximum size of the given JComponent for this UI.
Dimension
getMinimumSize(JComponent c)
This method returns the minimum size of the given JComponent for this UI.
protected void
installComponents()
This method installs the needed components for the JToolBar.
protected void
installDefaults()
This method installs the defaults as specified by the look and feel.
protected void
installKeyboardActions()
This method installs the keyboard actions for the JToolBar as specified by the look and feel.
protected void
installListeners()
This method installs listeners for the JToolBar.
protected void
installNonRolloverBorders(JComponent c)
This method installs non rollover borders for each component inside the given JComponent.
protected void
installNormalBorders(JComponent c)
This method installs normal (or their original) borders for each component inside the given JComponent.
protected void
installRolloverBorders(JComponent c)
This method install rollover borders for each component inside the given JComponent.
void
installUI(JComponent c)
This method installs the UI for the given JComponent.
boolean
isFloating()
This method returns whether the JToolBar is floating.
boolean
isRolloverBorders()
This method returns whether rollover borders have been set.
protected void
navigateFocusedComp(int direction)
This method navigates in the given direction giving focus to the next component in the given direction.
protected void
setBorderToNonRollover(Component c)
This method sets the border of the given component to a non rollover border.
protected void
setBorderToNormal(Component c)
This method sets the border of the given component to its original value.
protected void
setBorderToRollover(Component c)
This method sets the border of the given component to a rollover border.
void
setDockingColor(Color c)
This method sets the docking color.
void
setFloating(boolean b, Point p)
This method sets the floating property for the JToolBar.
void
setFloatingColor(Color c)
This method sets the color displayed when the JToolBar is not in a dockable area.
void
setFloatingLocation(int x, int y)
This method sets the floating location of the JToolBar.
void
setOrientation(int orientation)
This is a convenience method for changing the orientation of the JToolBar.
void
setRolloverBorders(boolean rollover)
This method changes the child components to have rollover borders if the given parameter is true.
protected void
uninstallComponents()
This method uninstall UI installed components from the JToolBar.
protected void
uninstallDefaults()
This method removes the defaults installed by the Look and Feel.
protected void
uninstallKeyboardActions()
This method uninstalls keyboard actions installed by the UI.
protected void
uninstallListeners()
This method uninstalls listeners installed by the UI.
void
uninstallUI(JComponent c)
This method uninstalls the UI.

Methods inherited from class javax.swing.plaf.ComponentUI

contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

constraintBeforeFloating

protected String constraintBeforeFloating
The last known BorderLayout constraint before floating.

dockingBorderColor

protected Color dockingBorderColor
The color of the border when it is dockable.

dockingColor

protected Color dockingColor
The background color of the JToolBar when it is dockable.

dockingListener

protected MouseInputListener dockingListener
The docking listener responsible for mouse events on the JToolBar.

downKey

protected KeyStroke downKey

Deprecated. since JDK1.3.


dragWindow

protected BasicToolBarUI.DragWindow dragWindow
The window used for dragging the JToolBar.

floatingBorderColor

protected Color floatingBorderColor
The color of the border when it is not dockable.

floatingColor

protected Color floatingColor
The background color of the JToolBar when it is not dockable.

focusedCompIndex

protected int focusedCompIndex
The index of the focused component.

leftKey

protected KeyStroke leftKey

Deprecated. since JDK1.3.


propertyListener

protected PropertyChangeListener propertyListener
The PropertyChangeListener for the JToolBar.

rightKey

protected KeyStroke rightKey

Deprecated. since JDK1.3.


toolBar

protected JToolBar toolBar
The JToolBar this UI delegate is responsible for.

toolBarContListener

protected ContainerListener toolBarContListener
The Container listener for the JToolBar.

toolBarFocusListener

protected FocusListener toolBarFocusListener
The Focus listener for the JToolBar.

upKey

protected KeyStroke upKey

Deprecated. since JDK1.3.

Constructor Details

BasicToolBarUI

public BasicToolBarUI()
This method creates a new BasicToolBarUI object for the given JToolBar.

Method Details

canDock

public boolean canDock(Component c,
                       Point p)
This method returns whether the JToolBar can dock at the given position.
Parameters:
c - The component to try to dock in.
p - The position of the mouse cursor relative to the given component.
Returns:
Whether the JToolBar can dock.

createDockingListener

protected MouseInputListener createDockingListener()
This method creates a new DockingListener for the JToolBar.
Returns:
A new DockingListener for the JToolBar.

createDragWindow

protected BasicToolBarUI.DragWindow createDragWindow(JToolBar toolbar)
This method creates a new DragWindow for the given JToolBar.
Parameters:
toolbar - The JToolBar to create a DragWindow for.
Returns:
A new DragWindow.

createFloatingFrame

protected JFrame createFloatingFrame(JToolBar toolbar)
This method creates a new floating frame for the JToolBar. By default, this UI uses createFloatingWindow instead. This method of creating a floating frame is deprecated.
Parameters:
toolbar - The JToolBar to create a floating frame for.
Returns:
A new floating frame.

createFloatingWindow

protected RootPaneContainer createFloatingWindow(JToolBar toolbar)
This method creates a new floating window for the JToolBar. This is the method used by default to create a floating container for the JToolBar.
Parameters:
toolbar - The JToolBar to create a floating window for.
Returns:
A new floating window.

createFrameListener

protected WindowListener createFrameListener()
This method creates a new WindowListener for the JToolBar.
Returns:
A new WindowListener.

createNonRolloverBorder

protected Border createNonRolloverBorder()
This method creates a new nonRolloverBorder for JButtons when the JToolBar's rollover property is set to false.
Returns:
A new NonRolloverBorder.

createPropertyListener

protected PropertyChangeListener createPropertyListener()
This method creates a new PropertyChangeListener for the JToolBar.
Returns:
A new PropertyChangeListener.

createRolloverBorder

protected Border createRolloverBorder()
This method creates a new rollover border for JButtons when the JToolBar's rollover property is set to true.
Returns:
A new rollover border.

createToolBarContListener

protected ContainerListener createToolBarContListener()
This method creates a new Container listener for the JToolBar.
Returns:
A new Container listener.

createToolBarFocusListener

protected FocusListener createToolBarFocusListener()
This method creates a new FocusListener for the JToolBar.
Returns:
A new FocusListener for the JToolBar.

createUI

public static ComponentUI createUI(JComponent c)
This method creates a new UI delegate for the given JComponent.
Overrides:
createUI in interface ComponentUI
Parameters:
c - The JComponent to create a UI delegate for.
Returns:
A new UI delegate.

dragTo

protected void dragTo(Point position,
                      Point origin)
This method is called to drag the DragWindow around when the JToolBar is being dragged around.
Parameters:
position - The mouse cursor coordinates relative to the JToolBar.
origin - The screen position of the JToolBar.

floatAt

protected void floatAt(Point position,
                       Point origin)
This method is used at the end of a drag session to place the frame in either its original parent as a docked JToolBar or in its floating frame.
Parameters:
position - The position of the mouse cursor relative to the JToolBar.
origin - The screen position of the JToolBar before the drag session started.

getDockingColor

public Color getDockingColor()
This method returns the docking color.
Returns:
The docking color.

getFloatingColor

public Color getFloatingColor()
This method returns the Color which is displayed when over a floating area.
Returns:
The color which is displayed when over a floating area.

getMaximumSize

public Dimension getMaximumSize(JComponent c)
This method returns the maximum size of the given JComponent for this UI.
Overrides:
getMaximumSize in interface ComponentUI
Parameters:
c - The JComponent to find the maximum size for.
Returns:
The maximum size for this UI.

getMinimumSize

public Dimension getMinimumSize(JComponent c)
This method returns the minimum size of the given JComponent for this UI.
Overrides:
getMinimumSize in interface ComponentUI
Parameters:
c - The JComponent to find a minimum size for.
Returns:
The minimum size for this UI.

installComponents

protected void installComponents()
This method installs the needed components for the JToolBar.

installDefaults

protected void installDefaults()
This method installs the defaults as specified by the look and feel.

installKeyboardActions

protected void installKeyboardActions()
This method installs the keyboard actions for the JToolBar as specified by the look and feel.

installListeners

protected void installListeners()
This method installs listeners for the JToolBar.

installNonRolloverBorders

protected void installNonRolloverBorders(JComponent c)
This method installs non rollover borders for each component inside the given JComponent.
Parameters:
c - The JComponent whose children need to have non rollover borders installed.

installNormalBorders

protected void installNormalBorders(JComponent c)
This method installs normal (or their original) borders for each component inside the given JComponent.
Parameters:
c - The JComponent whose children need to have their original borders installed.

installRolloverBorders

protected void installRolloverBorders(JComponent c)
This method install rollover borders for each component inside the given JComponent.
Parameters:
c - The JComponent whose children need to have rollover borders installed.

installUI

public void installUI(JComponent c)
This method installs the UI for the given JComponent.
Overrides:
installUI in interface ComponentUI
Parameters:
c - The JComponent to install a UI for.

isFloating

public boolean isFloating()
This method returns whether the JToolBar is floating.
Returns:
Whether the JToolBar is floating.

isRolloverBorders

public boolean isRolloverBorders()
This method returns whether rollover borders have been set.
Returns:
Whether rollover borders have been set.

navigateFocusedComp

protected void navigateFocusedComp(int direction)
This method navigates in the given direction giving focus to the next component in the given direction.
Parameters:
direction - The direction to give focus to.

setBorderToNonRollover

protected void setBorderToNonRollover(Component c)
This method sets the border of the given component to a non rollover border.
Parameters:
c - The Component whose border needs to be set.

setBorderToNormal

protected void setBorderToNormal(Component c)
This method sets the border of the given component to its original value.
Parameters:
c - The Component whose border needs to be set.

setBorderToRollover

protected void setBorderToRollover(Component c)
This method sets the border of the given component to a rollover border.
Parameters:
c - The Component whose border needs to be set.

setDockingColor

public void setDockingColor(Color c)
This method sets the docking color.
Parameters:
c - The docking color.

setFloating

public void setFloating(boolean b,
                        Point p)
This method sets the floating property for the JToolBar.
Parameters:
b - Whether the JToolBar is floating.
p - FIXME

setFloatingColor

public void setFloatingColor(Color c)
This method sets the color displayed when the JToolBar is not in a dockable area.
Parameters:
c - The floating color.

setFloatingLocation

public void setFloatingLocation(int x,
                                int y)
This method sets the floating location of the JToolBar.
Parameters:
x - The x coordinate for the floating frame.
y - The y coordinate for the floating frame.

setOrientation

public void setOrientation(int orientation)
This is a convenience method for changing the orientation of the JToolBar.
Parameters:
orientation - The new orientation.

setRolloverBorders

public void setRolloverBorders(boolean rollover)
This method changes the child components to have rollover borders if the given parameter is true. Otherwise, the components are set to have non rollover borders.
Parameters:
rollover - Whether the children will have rollover borders.

uninstallComponents

protected void uninstallComponents()
This method uninstall UI installed components from the JToolBar.

uninstallDefaults

protected void uninstallDefaults()
This method removes the defaults installed by the Look and Feel.

uninstallKeyboardActions

protected void uninstallKeyboardActions()
This method uninstalls keyboard actions installed by the UI.

uninstallListeners

protected void uninstallListeners()
This method uninstalls listeners installed by the UI.

uninstallUI

public void uninstallUI(JComponent c)
This method uninstalls the UI.
Overrides:
uninstallUI in interface ComponentUI
Parameters:
c - The JComponent that is having this UI removed.

BasicToolBarUI.java -- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.