FileDocCategorySizeDatePackage
BasicToolBarUI.javaAPI DocJava SE 6 API43355Tue Jun 10 00:26:48 BST 2008javax.swing.plaf.basic

BasicToolBarUI

public class BasicToolBarUI extends ToolBarUI implements SwingConstants
A Basic L&F implementation of ToolBarUI. This implementation is a "combined" view/controller.

version
1.102 04/12/06
author
Georges Saab
author
Jeff Shapiro

Fields Summary
protected JToolBar
toolBar
private boolean
floating
private int
floatingX
private int
floatingY
private JFrame
floatingFrame
private RootPaneContainer
floatingToolBar
protected DragWindow
dragWindow
private Container
dockingSource
private int
dockingSensitivity
protected int
focusedCompIndex
protected Color
dockingColor
protected Color
floatingColor
protected Color
dockingBorderColor
protected Color
floatingBorderColor
protected MouseInputListener
dockingListener
protected PropertyChangeListener
propertyListener
protected ContainerListener
toolBarContListener
protected FocusListener
toolBarFocusListener
private Handler
handler
protected String
constraintBeforeFloating
private static String
IS_ROLLOVER
private static Border
rolloverBorder
private static Border
nonRolloverBorder
private static Border
nonRolloverToggleBorder
private boolean
rolloverBorders
private HashMap
borderTable
private Hashtable
rolloverTable
protected KeyStroke
upKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
downKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
leftKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
rightKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
private static String
FOCUSED_COMP_INDEX
Constructors Summary
Methods Summary
private java.lang.StringcalculateConstraint()

	String constraint = null;
	LayoutManager lm = dockingSource.getLayout();
	if (lm instanceof BorderLayout) {
	    constraint = (String)((BorderLayout)lm).getConstraints(toolBar);
	}
	return (constraint != null) ? constraint : constraintBeforeFloating;
    
public booleancanDock(java.awt.Component c, java.awt.Point p)

	return (p != null && getDockingConstraint(c, p) != null);
    
protected javax.swing.event.MouseInputListenercreateDockingListener()

        getHandler().tb = toolBar;
        return getHandler();
    
protected javax.swing.plaf.basic.BasicToolBarUI$DragWindowcreateDragWindow(javax.swing.JToolBar toolbar)

	Window frame = null;
	if(toolBar != null) {
	    Container p;
	    for(p = toolBar.getParent() ; p != null && !(p instanceof Window) ;
		p = p.getParent());
	    if(p != null && p instanceof Window)
		frame = (Window) p;
	}
	if(floatingToolBar == null) {
	    floatingToolBar = createFloatingWindow(toolBar);
	}
	if (floatingToolBar instanceof Window) frame = (Window) floatingToolBar;
	DragWindow dragWindow = new DragWindow(frame);
	return dragWindow;
    
protected javax.swing.JFramecreateFloatingFrame(javax.swing.JToolBar toolbar)
No longer used, use BasicToolBarUI.createFloatingWindow(JToolBar)

see
#createFloatingWindow

	Window window = SwingUtilities.getWindowAncestor(toolbar);
	JFrame frame = new JFrame(toolbar.getName(),
				  (window != null) ? window.getGraphicsConfiguration() : null) {
	    // Override createRootPane() to automatically resize
	    // the frame when contents change
	    protected JRootPane createRootPane() {
		JRootPane rootPane = new JRootPane() {
		    private boolean packing = false;

		    public void validate() {
			super.validate();
			if (!packing) {
			    packing = true;
			    pack();
			    packing = false;
			}
		    }
		};
		rootPane.setOpaque(true);
		return rootPane;
	    }
	};
        frame.getRootPane().setName("ToolBar.FloatingFrame");
	frame.setResizable(false);
	WindowListener wl = createFrameListener();
	frame.addWindowListener(wl);
        return frame;
    
protected javax.swing.RootPaneContainercreateFloatingWindow(javax.swing.JToolBar toolbar)
Creates a window which contains the toolbar after it has been dragged out from its container

return
a RootPaneContainer object, containing the toolbar.
since
1.4

	class ToolBarDialog extends JDialog {
	    public ToolBarDialog(Frame owner, String title, boolean modal) {
		super(owner, title, modal);
	    }

	    public ToolBarDialog(Dialog owner, String title, boolean modal) {
		super(owner, title, modal);
	    }

	    // Override createRootPane() to automatically resize
	    // the frame when contents change
	    protected JRootPane createRootPane() {
		JRootPane rootPane = new JRootPane() {
		    private boolean packing = false;

		    public void validate() {
			super.validate();
			if (!packing) {
			    packing = true;
			    pack();
			    packing = false;
			}
		    }
		};
		rootPane.setOpaque(true);
		return rootPane;
	    }
	}

	JDialog dialog;
	Window window = SwingUtilities.getWindowAncestor(toolbar);
	if (window instanceof Frame) {
	    dialog = new ToolBarDialog((Frame)window, toolbar.getName(), false);
	} else if (window instanceof Dialog) {
	    dialog = new ToolBarDialog((Dialog)window, toolbar.getName(), false);
	} else {
	    dialog = new ToolBarDialog((Frame)null, toolbar.getName(), false);
	}

        dialog.getRootPane().setName("ToolBar.FloatingWindow");
	dialog.setTitle(toolbar.getName());
	dialog.setResizable(false);
	WindowListener wl = createFrameListener();
	dialog.addWindowListener(wl);
        return dialog;
    
protected java.awt.event.WindowListenercreateFrameListener()

	return new FrameListener();
    
protected javax.swing.border.BordercreateNonRolloverBorder()
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.

since
1.4

        Object border = UIManager.get("ToolBar.nonrolloverBorder");
        if (border != null) {
            return (Border)border;
        }
	UIDefaults table = UIManager.getLookAndFeelDefaults();
	return new CompoundBorder(new BasicBorders.ButtonBorder(
					   table.getColor("Button.shadow"),
                                           table.getColor("Button.darkShadow"),
                                           table.getColor("Button.light"),
                                           table.getColor("Button.highlight")),
				  new BasicBorders.RolloverMarginBorder());
    
private javax.swing.border.BordercreateNonRolloverToggleBorder()
Creates a non rollover border for Toggle buttons in the toolbar.

	UIDefaults table = UIManager.getLookAndFeelDefaults();
	return new CompoundBorder(new BasicBorders.RadioButtonBorder(
 					   table.getColor("ToggleButton.shadow"),
                                           table.getColor("ToggleButton.darkShadow"),
                                           table.getColor("ToggleButton.light"),
                                           table.getColor("ToggleButton.highlight")),
				  new BasicBorders.RolloverMarginBorder());
    
protected java.beans.PropertyChangeListenercreatePropertyListener()

        return getHandler();
    
protected javax.swing.border.BordercreateRolloverBorder()
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.

since
1.4

        Object border = UIManager.get("ToolBar.rolloverBorder");
        if (border != null) {
            return (Border)border;
        }
	UIDefaults table = UIManager.getLookAndFeelDefaults();
	return new CompoundBorder(new BasicBorders.RolloverButtonBorder(
					   table.getColor("controlShadow"),
                                           table.getColor("controlDkShadow"),
                                           table.getColor("controlHighlight"),
                                           table.getColor("controlLtHighlight")),
				  new BasicBorders.RolloverMarginBorder());
    
protected java.awt.event.ContainerListenercreateToolBarContListener()

        return getHandler();
    
protected java.awt.event.FocusListenercreateToolBarFocusListener()

        return getHandler();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)


          
    
	return new BasicToolBarUI();
    
protected voiddragTo(java.awt.Point position, java.awt.Point origin)

	if (toolBar.isFloatable() == true)
	{
	  try
	  {
	    if (dragWindow == null)
		dragWindow = createDragWindow(toolBar);
	    Point offset = dragWindow.getOffset();
	    if (offset == null) {
		Dimension size = toolBar.getPreferredSize();
		offset = new Point(size.width/2, size.height/2);
		dragWindow.setOffset(offset);
	    }
	    Point global = new Point(origin.x+ position.x,
				     origin.y+position.y);
	    Point dragPoint = new Point(global.x- offset.x, 
					global.y- offset.y);
	    if (dockingSource == null)
		dockingSource = toolBar.getParent();
		constraintBeforeFloating = calculateConstraint();	    
	    Point dockingPosition = dockingSource.getLocationOnScreen();
	    Point comparisonPoint = new Point(global.x-dockingPosition.x,
					      global.y-dockingPosition.y);
	    if (canDock(dockingSource, comparisonPoint)) {
		dragWindow.setBackground(getDockingColor());	
		String constraint = getDockingConstraint(dockingSource,
							 comparisonPoint);
		int orientation = mapConstraintToOrientation(constraint);
		dragWindow.setOrientation(orientation);
		dragWindow.setBorderColor(dockingBorderColor);
	    } else {
		dragWindow.setBackground(getFloatingColor());
		dragWindow.setBorderColor(floatingBorderColor);
	    }
	    
	    dragWindow.setLocation(dragPoint.x, dragPoint.y);
	    if (dragWindow.isVisible() == false) {
		Dimension size = toolBar.getPreferredSize();
		dragWindow.setSize(size.width, size.height);
		dragWindow.show();
	    }
	  }
	  catch ( IllegalComponentStateException e )
	  {
	  }
	}
    
protected voidfloatAt(java.awt.Point position, java.awt.Point origin)

	if(toolBar.isFloatable() == true)
	{
	  try
	  {
	    Point offset = dragWindow.getOffset();
	    if (offset == null) {
		offset = position;
		dragWindow.setOffset(offset);
	    }
	    Point global = new Point(origin.x+ position.x,
				     origin.y+position.y);
	    setFloatingLocation(global.x-offset.x, 
				global.y-offset.y);
	    if (dockingSource != null) { 
		Point dockingPosition = dockingSource.getLocationOnScreen();
		Point comparisonPoint = new Point(global.x-dockingPosition.x,
						  global.y-dockingPosition.y);
		if (canDock(dockingSource, comparisonPoint)) {
		    setFloating(false, comparisonPoint);
		} else {
		    setFloating(true, null);
		}
	    } else {
		setFloating(true, null);
	    }
	    dragWindow.setOffset(null);
	  }
	  catch ( IllegalComponentStateException e )
	  {
	  }
	}
    
public java.awt.ColorgetDockingColor()
Gets the color displayed when over a docking area

	return dockingColor;
    
private java.lang.StringgetDockingConstraint(java.awt.Component c, java.awt.Point p)

	if (p == null) return constraintBeforeFloating;
	if (c.contains(p)) {
	    dockingSensitivity = (toolBar.getOrientation() == JToolBar.HORIZONTAL)
						? toolBar.getSize().height
						: toolBar.getSize().width;
	    // North  (Base distance on height for now!)
	    if (p.y < dockingSensitivity && !isBlocked(c, BorderLayout.NORTH)) {
		return BorderLayout.NORTH;
	    }
	    // East  (Base distance on height for now!)
	    if (p.x >= c.getWidth() - dockingSensitivity && !isBlocked(c, BorderLayout.EAST)) {
		return BorderLayout.EAST;
	    }
	    // West  (Base distance on height for now!)
	    if (p.x < dockingSensitivity && !isBlocked(c, BorderLayout.WEST)) {
		return BorderLayout.WEST;
	    }
	    if (p.y >= c.getHeight() - dockingSensitivity && !isBlocked(c, BorderLayout.SOUTH)) {
		return BorderLayout.SOUTH;
	    }
	}
	return null;
    
public java.awt.ColorgetFloatingColor()
Gets the color displayed when over a floating area

	return floatingColor;
    
private javax.swing.plaf.basic.BasicToolBarUI$HandlergetHandler()

        if (handler == null) {
            handler = new Handler();
        }
        return handler;
    
javax.swing.InputMapgetInputMap(int condition)

	if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
	    return (InputMap)DefaultLookup.get(toolBar, this,
                    "ToolBar.ancestorInputMap");
	}
	return null;
    
protected javax.swing.border.BordergetNonRolloverBorder(javax.swing.AbstractButton b)
Returns a non-rollover border for the button.

param
b the button to calculate the non-rollover border for
return
the non-rollover border
see
#setBorderToNonRollover
since
1.6

        if (b instanceof JToggleButton) {
            return nonRolloverToggleBorder;
        } else {
            return nonRolloverBorder;
        }
    
protected javax.swing.border.BordergetRolloverBorder(javax.swing.AbstractButton b)
Returns a rollover border for the button.

param
b the button to calculate the rollover border for
return
the rollover border
see
#setBorderToRollover
since
1.6

        return rolloverBorder;
    
protected voidinstallComponents()

    
protected voidinstallDefaults()

 	LookAndFeel.installBorder(toolBar,"ToolBar.border");	
	LookAndFeel.installColorsAndFont(toolBar,
					      "ToolBar.background",
					      "ToolBar.foreground",
					      "ToolBar.font");
	// Toolbar specific defaults
	if ( dockingColor == null || dockingColor instanceof UIResource )
	    dockingColor = UIManager.getColor("ToolBar.dockingBackground");
	if ( floatingColor == null || floatingColor instanceof UIResource )
	    floatingColor = UIManager.getColor("ToolBar.floatingBackground");
	if ( dockingBorderColor == null || 
	     dockingBorderColor instanceof UIResource )
	    dockingBorderColor = UIManager.getColor("ToolBar.dockingForeground");
	if ( floatingBorderColor == null || 
	     floatingBorderColor instanceof UIResource )
	    floatingBorderColor = UIManager.getColor("ToolBar.floatingForeground");

	// ToolBar rollover button borders
	Object rolloverProp = toolBar.getClientProperty( IS_ROLLOVER );
        if (rolloverProp == null) {
            rolloverProp = UIManager.get("ToolBar.isRollover");
        }
	if ( rolloverProp != null ) {
	    rolloverBorders = ((Boolean)rolloverProp).booleanValue();
	}

	if (rolloverBorder == null) {
	    rolloverBorder = createRolloverBorder();
	}
	if (nonRolloverBorder == null) {
	    nonRolloverBorder = createNonRolloverBorder();
	}
	if (nonRolloverToggleBorder == null) {
	    nonRolloverToggleBorder = createNonRolloverToggleBorder();
	}


	setRolloverBorders( isRolloverBorders() );
    
protected voidinstallKeyboardActions()

	InputMap km = getInputMap(JComponent.
				  WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

	SwingUtilities.replaceUIInputMap(toolBar, JComponent.
					 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
					 km);

    LazyActionMap.installLazyActionMap(toolBar, BasicToolBarUI.class,
            "ToolBar.actionMap");
    
protected voidinstallListeners()

        dockingListener = createDockingListener( );

        if ( dockingListener != null )
        {
	    toolBar.addMouseMotionListener( dockingListener );
	    toolBar.addMouseListener( dockingListener );
	}

	propertyListener = createPropertyListener();  // added in setFloating
	if (propertyListener != null) {
	    toolBar.addPropertyChangeListener(propertyListener);
	}

	toolBarContListener = createToolBarContListener();
        if ( toolBarContListener != null ) {
	    toolBar.addContainerListener( toolBarContListener );
	}

	toolBarFocusListener = createToolBarFocusListener();

        if ( toolBarFocusListener != null )
        {
	    // Put focus listener on all components in toolbar
	    Component[] components = toolBar.getComponents();

	    for ( int i = 0; i < components.length; ++i )
	    {
	        components[ i ].addFocusListener( toolBarFocusListener );
	    }
	}
    
protected voidinstallNonRolloverBorders(javax.swing.JComponent c)
Installs non-rollover borders on all the child components of the JComponent. A non-rollover border is the border that is installed on the child component while it is in the toolbar.

This is a convenience method to call setBorderToNonRollover for each child component.

param
c container which holds the child components (usally a JToolBar)
see
#setBorderToNonRollover
since
1.4

	// Put non-rollover borders on buttons. These borders reduce the margin.
	Component[] components = c.getComponents();

	for ( int i = 0; i < components.length; ++i ) {
	    if ( components[ i ] instanceof JComponent ) {
		( (JComponent)components[ i ] ).updateUI();
		setBorderToNonRollover( components[ i ] );
	    }
	}
    
protected voidinstallNormalBorders(javax.swing.JComponent c)
Installs normal borders on all the child components of the JComponent. A normal border is the original border that was installed on the child component before it was added to the toolbar.

This is a convenience method to call setBorderNormal for each child component.

param
c container which holds the child components (usally a JToolBar)
see
#setBorderToNonRollover
since
1.4

	// Put back the normal borders on buttons
	Component[] components = c.getComponents();

	for ( int i = 0; i < components.length; ++i ) {
	    setBorderToNormal( components[ i ] );
	}
    
protected voidinstallRolloverBorders(javax.swing.JComponent c)
Installs rollover borders on all the child components of the JComponent.

This is a convenience method to call setBorderToRollover for each child component.

param
c container which holds the child components (usally a JToolBar)
see
#setBorderToRollover
since
1.4

	// Put rollover borders on buttons
	Component[] components = c.getComponents();

	for ( int i = 0; i < components.length; ++i ) {
	    if ( components[ i ] instanceof JComponent ) {
		( (JComponent)components[ i ] ).updateUI();
		setBorderToRollover( components[ i ] );
	    }
	}
    
public voidinstallUI(javax.swing.JComponent c)

	toolBar = (JToolBar) c;

	// Set defaults
        installDefaults();
	installComponents();
        installListeners();
	installKeyboardActions();

        // Initialize instance vars
        dockingSensitivity = 0;
        floating = false;
        floatingX = floatingY = 0;
        floatingToolBar = null;

	setOrientation( toolBar.getOrientation() );
        LookAndFeel.installProperty(c, "opaque", Boolean.TRUE);

	if ( c.getClientProperty( FOCUSED_COMP_INDEX ) != null )
	{
	    focusedCompIndex = ( (Integer) ( c.getClientProperty( FOCUSED_COMP_INDEX ) ) ).intValue();
	}
    
private booleanisBlocked(java.awt.Component comp, java.lang.Object constraint)

	if (comp instanceof Container) {
	    Container cont = (Container)comp;
	    LayoutManager lm = cont.getLayout();
	    if (lm instanceof BorderLayout) {
		BorderLayout blm = (BorderLayout)lm;
		Component c = blm.getLayoutComponent(cont, constraint);
		return (c != null && c != toolBar);
	    }
	}
	return false;
    
public booleanisFloating()

	return floating;
    
public booleanisRolloverBorders()
Returns a flag to determine whether rollover button borders are enabled.

return
true if rollover borders are enabled; false otherwise
see
#setRolloverBorders
since
1.4

        return rolloverBorders;
    
static voidloadActionMap(javax.swing.plaf.basic.LazyActionMap map)

        map.put(new Actions(Actions.NAVIGATE_RIGHT));
        map.put(new Actions(Actions.NAVIGATE_LEFT));
        map.put(new Actions(Actions.NAVIGATE_UP));
        map.put(new Actions(Actions.NAVIGATE_DOWN));
    
private intmapConstraintToOrientation(java.lang.String constraint)

	int orientation = toolBar.getOrientation();

	if ( constraint != null )
	{
	    if ( constraint.equals(BorderLayout.EAST) || constraint.equals(BorderLayout.WEST) )
	        orientation = JToolBar.VERTICAL;
	    else if ( constraint.equals(BorderLayout.NORTH) || constraint.equals(BorderLayout.SOUTH) )
	        orientation = JToolBar.HORIZONTAL;
	}

	return orientation;
    
protected voidnavigateFocusedComp(int direction)

        int nComp = toolBar.getComponentCount();
	int j;

        switch ( direction )
	{
	    case EAST:
	    case SOUTH:

		if ( focusedCompIndex < 0 || focusedCompIndex >= nComp ) break;

		j = focusedCompIndex + 1;

		while ( j != focusedCompIndex )
		{
		    if ( j >= nComp ) j = 0;
		    Component comp = toolBar.getComponentAtIndex( j++ );

		    if ( comp != null && comp.isFocusTraversable() && comp.isEnabled() )
		    {
		        comp.requestFocus();
			break;
		    }
		}

	        break;

	    case WEST:
	    case NORTH:

		if ( focusedCompIndex < 0 || focusedCompIndex >= nComp ) break;

		j = focusedCompIndex - 1;

		while ( j != focusedCompIndex )
		{
		    if ( j < 0 ) j = nComp - 1;
		    Component comp = toolBar.getComponentAtIndex( j-- );

		    if ( comp != null && comp.isFocusTraversable() && comp.isEnabled() )
		    {
		        comp.requestFocus();
			break;
		    }
		}

	        break;

	    default:
	        break;
	}
    
protected voidpaintDragWindow(java.awt.Graphics g)
Paints the contents of the window used for dragging.

param
g Graphics to paint to.
throws
NullPointerException is g is null
since
1.5

        g.setColor(dragWindow.getBackground());	    
        int w = dragWindow.getWidth();
        int h = dragWindow.getHeight();
        g.fillRect(0, 0, w, h);
        g.setColor(dragWindow.getBorderColor());
        g.drawRect(0, 0, w - 1, h - 1);	    
    
protected voidsetBorderToNonRollover(java.awt.Component c)
Sets the border of the component to have a non-rollover border which was created by createNonRolloverBorder.

param
c component which will have a non-rollover border installed
see
#createNonRolloverBorder
since
1.4

        if (c instanceof AbstractButton) {
	    AbstractButton b = (AbstractButton)c;
	    
	    Border border = (Border)borderTable.get(b);
	    if (border == null || border instanceof UIResource) {
		borderTable.put(b, b.getBorder());
	    }

	    // Only set the border if its the default border
	    if (b.getBorder() instanceof UIResource) {
                b.setBorder(getNonRolloverBorder(b));
	    }
	    rolloverTable.put(b, b.isRolloverEnabled()?
			      Boolean.TRUE: Boolean.FALSE);
	    b.setRolloverEnabled(false);
	}
    
protected voidsetBorderToNormal(java.awt.Component c)
Sets the border of the component to have a normal border. A normal border is the original border that was installed on the child component before it was added to the toolbar.

param
c component which will have a normal border re-installed
see
#createNonRolloverBorder
since
1.4

        if (c instanceof AbstractButton) {
	    AbstractButton b = (AbstractButton)c;

	    Border border = (Border)borderTable.remove(b);
	    b.setBorder(border);

	    Boolean value = (Boolean)rolloverTable.remove(b);
	    if (value != null) {
		b.setRolloverEnabled(value.booleanValue());
	    }
	}
    
protected voidsetBorderToRollover(java.awt.Component c)
Sets the border of the component to have a rollover border which was created by createRolloverBorder.

param
c component which will have a rollover border installed
see
#createRolloverBorder
since
1.4

        if (c instanceof AbstractButton) {
	    AbstractButton b = (AbstractButton)c;
	    
	    Border border = (Border)borderTable.get(b);
	    if (border == null || border instanceof UIResource) {
		borderTable.put(b, b.getBorder());
	    }

	    // Only set the border if its the default border
	    if (b.getBorder() instanceof UIResource) {
                b.setBorder(getRolloverBorder(b));
	    }

	    rolloverTable.put(b, b.isRolloverEnabled()?
			      Boolean.TRUE: Boolean.FALSE);
	    b.setRolloverEnabled(true);
	}
    
public voidsetDockingColor(java.awt.Color c)
Sets the color displayed when over a docking area

	this.dockingColor = c;
    
public voidsetFloating(boolean b, java.awt.Point p)

 	if (toolBar.isFloatable() == true) {
 	    boolean visible = false;
 	    Window ancestor = SwingUtilities.getWindowAncestor(toolBar);
 	    if (ancestor != null) {
 	        visible = ancestor.isVisible();
 	    }
	    if (dragWindow != null)
		dragWindow.setVisible(false);
	    this.floating = b;
	    if (floatingToolBar == null) {
	        floatingToolBar = createFloatingWindow(toolBar);
	    }
	    if (b == true)
	    {
		if (dockingSource == null)
		{
		    dockingSource = toolBar.getParent();
		    dockingSource.remove(toolBar);
		}
		constraintBeforeFloating = calculateConstraint();
		if ( propertyListener != null )
                    UIManager.addPropertyChangeListener( propertyListener );
		floatingToolBar.getContentPane().add(toolBar,BorderLayout.CENTER);
		if (floatingToolBar instanceof Window) {
		    ((Window)floatingToolBar).pack();
		    ((Window)floatingToolBar).setLocation(floatingX, floatingY);
		    if (visible) {
		        ((Window)floatingToolBar).show();
		    } else {
		        ancestor.addWindowListener(new WindowAdapter() { 
		            public void windowOpened(WindowEvent e) {
		                ((Window)floatingToolBar).show();
		            }
		        });
		    }
		}
	    } else {
		if (floatingToolBar == null)
		    floatingToolBar = createFloatingWindow(toolBar);
		if (floatingToolBar instanceof Window) ((Window)floatingToolBar).setVisible(false);
		floatingToolBar.getContentPane().remove(toolBar);
		String constraint = getDockingConstraint(dockingSource,
							 p);
		if (constraint == null) {
		    constraint = BorderLayout.NORTH;
		}
		int orientation = mapConstraintToOrientation(constraint);
		setOrientation(orientation);
		if (dockingSource== null)
		    dockingSource = toolBar.getParent();
		if ( propertyListener != null )
		    UIManager.removePropertyChangeListener( propertyListener );
		dockingSource.add(constraint, toolBar);
	    }
 	    dockingSource.invalidate();
 	    Container dockingSourceParent = dockingSource.getParent();
	    if (dockingSourceParent != null) 
		dockingSourceParent.validate();
	    dockingSource.repaint();
	}
    
public voidsetFloatingColor(java.awt.Color c)
Sets the color displayed when over a floating area

	this.floatingColor = c;
    
public voidsetFloatingLocation(int x, int y)

	floatingX = x;
	floatingY = y;
    
public voidsetOrientation(int orientation)

	
        toolBar.setOrientation( orientation );

	if (dragWindow !=null)
	    dragWindow.setOrientation(orientation);
    
public voidsetRolloverBorders(boolean rollover)
Sets the flag for enabling rollover borders on the toolbar and it will also install the apropriate border depending on the state of the flag.

param
rollover if true, rollover borders are installed. Otherwise non-rollover borders are installed
see
#isRolloverBorders
since
1.4

        rolloverBorders = rollover;
	    
	if ( rolloverBorders )	{
	    installRolloverBorders( toolBar );
	} else	{
	    installNonRolloverBorders( toolBar );
	}
    
protected voiduninstallComponents()

    
protected voiduninstallDefaults()

	LookAndFeel.uninstallBorder(toolBar);
        dockingColor = null;
        floatingColor = null;
        dockingBorderColor = null;
        floatingBorderColor = null;

	installNormalBorders(toolBar);

	rolloverBorder = null;
	nonRolloverBorder = null;
	nonRolloverToggleBorder = null;
    
protected voiduninstallKeyboardActions()

	SwingUtilities.replaceUIActionMap(toolBar, null);
	SwingUtilities.replaceUIInputMap(toolBar, JComponent.
					 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
					 null);
    
protected voiduninstallListeners()

        if ( dockingListener != null )
        {
	    toolBar.removeMouseMotionListener(dockingListener);
	    toolBar.removeMouseListener(dockingListener);

            dockingListener = null;
	}

	if ( propertyListener != null )
	{
	    toolBar.removePropertyChangeListener(propertyListener);
	    propertyListener = null;  // removed in setFloating
	}

	if ( toolBarContListener != null )
	{
	    toolBar.removeContainerListener( toolBarContListener );
	    toolBarContListener = null;
	}

        if ( toolBarFocusListener != null )
        {
	    // Remove focus listener from all components in toolbar
	    Component[] components = toolBar.getComponents();

	    for ( int i = 0; i < components.length; ++i )
	    {
	        components[ i ].removeFocusListener( toolBarFocusListener );
	    }

	    toolBarFocusListener = null;
	}
        handler = null;
    
public voiduninstallUI(javax.swing.JComponent c)


        // Clear defaults
        uninstallDefaults();
	uninstallComponents();
        uninstallListeners();
	uninstallKeyboardActions();

        // Clear instance vars
	if (isFloating() == true)
	    setFloating(false, null);

        floatingToolBar = null;
        dragWindow = null;
        dockingSource = null;

        c.putClientProperty( FOCUSED_COMP_INDEX, new Integer( focusedCompIndex ) );