BasicToolBarUI (Java Platform SE 8 ) (original) (raw)
- javax.swing.plaf.ComponentUI
- javax.swing.plaf.ToolBarUI
- javax.swing.plaf.basic.BasicToolBarUI
- javax.swing.plaf.ToolBarUI
All Implemented Interfaces:
SwingConstants
Direct Known Subclasses:
MetalToolBarUI, SynthToolBarUI
public class BasicToolBarUI
extends ToolBarUI
implements SwingConstants
A Basic L&F implementation of ToolBarUI. This implementation is a "combined" view/controller.
Nested Class Summary
Nested Classes
Modifier and Type Class Description class BasicToolBarUI.DockingListener This class should be treated as a "protected" inner class. protected class BasicToolBarUI.DragWindow protected class BasicToolBarUI.FrameListener protected class BasicToolBarUI.PropertyListener protected class BasicToolBarUI.ToolBarContListener protected class BasicToolBarUI.ToolBarFocusListener Field Summary
Fields
Modifier and Type Field Description protected String constraintBeforeFloating protected Color dockingBorderColor protected Color dockingColor protected MouseInputListener dockingListener protected KeyStroke downKey Deprecated. protected BasicToolBarUI.DragWindow dragWindow protected Color floatingBorderColor protected Color floatingColor protected int focusedCompIndex protected KeyStroke leftKey Deprecated. protected PropertyChangeListener propertyListener protected KeyStroke rightKey Deprecated. protected JToolBar toolBar protected ContainerListener toolBarContListener protected FocusListener toolBarFocusListener protected KeyStroke upKey Deprecated. * ### Fields inherited from interface javax.swing.[SwingConstants](../../../../javax/swing/SwingConstants.html "interface in javax.swing") `[BOTTOM](../../../../javax/swing/SwingConstants.html#BOTTOM), [CENTER](../../../../javax/swing/SwingConstants.html#CENTER), [EAST](../../../../javax/swing/SwingConstants.html#EAST), [HORIZONTAL](../../../../javax/swing/SwingConstants.html#HORIZONTAL), [LEADING](../../../../javax/swing/SwingConstants.html#LEADING), [LEFT](../../../../javax/swing/SwingConstants.html#LEFT), [NEXT](../../../../javax/swing/SwingConstants.html#NEXT), [NORTH](../../../../javax/swing/SwingConstants.html#NORTH), [NORTH_EAST](../../../../javax/swing/SwingConstants.html#NORTH%5FEAST), [NORTH_WEST](../../../../javax/swing/SwingConstants.html#NORTH%5FWEST), [PREVIOUS](../../../../javax/swing/SwingConstants.html#PREVIOUS), [RIGHT](../../../../javax/swing/SwingConstants.html#RIGHT), [SOUTH](../../../../javax/swing/SwingConstants.html#SOUTH), [SOUTH_EAST](../../../../javax/swing/SwingConstants.html#SOUTH%5FEAST), [SOUTH_WEST](../../../../javax/swing/SwingConstants.html#SOUTH%5FWEST), [TOP](../../../../javax/swing/SwingConstants.html#TOP), [TRAILING](../../../../javax/swing/SwingConstants.html#TRAILING), [VERTICAL](../../../../javax/swing/SwingConstants.html#VERTICAL), [WEST](../../../../javax/swing/SwingConstants.html#WEST)`
Constructor Summary
Constructors
Constructor Description BasicToolBarUI() Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type Method Description boolean canDock(Component c,Point p) protected MouseInputListener createDockingListener() protected BasicToolBarUI.DragWindow createDragWindow(JToolBar toolbar) protected JFrame createFloatingFrame(JToolBar toolbar) No longer used, use BasicToolBarUI.createFloatingWindow(JToolBar) protected RootPaneContainer createFloatingWindow(JToolBar toolbar) Creates a window which contains the toolbar after it has been dragged out from its container protected WindowListener createFrameListener() protected Border createNonRolloverBorder() Creates the non rollover border for toolbar components. protected PropertyChangeListener createPropertyListener() protected Border createRolloverBorder() Creates a rollover border for toolbar components. protected ContainerListener createToolBarContListener() protected FocusListener createToolBarFocusListener() static ComponentUI createUI(JComponent c) protected void dragTo(Point position,Point origin) protected void floatAt(Point position,Point origin) Color getDockingColor() Gets the color displayed when over a docking area Color getFloatingColor() Gets the color displayed when over a floating area protected Border getNonRolloverBorder(AbstractButton b) Returns a non-rollover border for the button. protected Border getRolloverBorder(AbstractButton b) Returns a rollover border for the button. protected void installComponents() protected void installDefaults() protected void installKeyboardActions() protected void installListeners() protected void installNonRolloverBorders(JComponent c) Installs non-rollover borders on all the child components of the JComponent. protected void installNormalBorders(JComponent c) Installs normal borders on all the child components of the JComponent. protected void installRolloverBorders(JComponent c) Installs rollover borders on all the child components of the JComponent. void installUI(JComponent c) Configures the specified component appropriately for the look and feel. boolean isFloating() boolean isRolloverBorders() Returns a flag to determine whether rollover button borders are enabled. protected void navigateFocusedComp(int direction) protected void paintDragWindow(Graphics g) Paints the contents of the window used for dragging. protected void setBorderToNonRollover(Component c) Sets the border of the component to have a non-rollover border which was created by the createNonRolloverBorder() method. protected void setBorderToNormal(Component c) Sets the border of the component to have a normal border. protected void setBorderToRollover(Component c) Sets the border of the component to have a rollover border which was created by the createRolloverBorder() method. void setDockingColor(Color c) Sets the color displayed when over a docking area void setFloating(boolean b,Point p) void setFloatingColor(Color c) Sets the color displayed when over a floating area void setFloatingLocation(int x, int y) void setOrientation(int orientation) void setRolloverBorders(boolean rollover) Sets the flag for enabling rollover borders on the toolbar and it will also install the appropriate border depending on the state of the flag. protected void uninstallComponents() protected void uninstallDefaults() protected void uninstallKeyboardActions() protected void uninstallListeners() void uninstallUI(JComponent c) Reverses configuration which was done on the specified component duringinstallUI. * ### Methods inherited from class javax.swing.plaf.[ComponentUI](../../../../javax/swing/plaf/ComponentUI.html "class in javax.swing.plaf") `[contains](../../../../javax/swing/plaf/ComponentUI.html#contains-javax.swing.JComponent-int-int-), [getAccessibleChild](../../../../javax/swing/plaf/ComponentUI.html#getAccessibleChild-javax.swing.JComponent-int-), [getAccessibleChildrenCount](../../../../javax/swing/plaf/ComponentUI.html#getAccessibleChildrenCount-javax.swing.JComponent-), [getBaseline](../../../../javax/swing/plaf/ComponentUI.html#getBaseline-javax.swing.JComponent-int-int-), [getBaselineResizeBehavior](../../../../javax/swing/plaf/ComponentUI.html#getBaselineResizeBehavior-javax.swing.JComponent-), [getMaximumSize](../../../../javax/swing/plaf/ComponentUI.html#getMaximumSize-javax.swing.JComponent-), [getMinimumSize](../../../../javax/swing/plaf/ComponentUI.html#getMinimumSize-javax.swing.JComponent-), [getPreferredSize](../../../../javax/swing/plaf/ComponentUI.html#getPreferredSize-javax.swing.JComponent-), [paint](../../../../javax/swing/plaf/ComponentUI.html#paint-java.awt.Graphics-javax.swing.JComponent-), [update](../../../../javax/swing/plaf/ComponentUI.html#update-java.awt.Graphics-javax.swing.JComponent-)` * ### Methods inherited from class java.lang.[Object](../../../../java/lang/Object.html "class in java.lang") `[clone](../../../../java/lang/Object.html#clone--), [equals](../../../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../../../java/lang/Object.html#finalize--), [getClass](../../../../java/lang/Object.html#getClass--), [hashCode](../../../../java/lang/Object.html#hashCode--), [notify](../../../../java/lang/Object.html#notify--), [notifyAll](../../../../java/lang/Object.html#notifyAll--), [toString](../../../../java/lang/Object.html#toString--), [wait](../../../../java/lang/Object.html#wait--), [wait](../../../../java/lang/Object.html#wait-long-), [wait](../../../../java/lang/Object.html#wait-long-int-)`
Field Detail
* #### toolBar protected [JToolBar](../../../../javax/swing/JToolBar.html "class in javax.swing") toolBar * #### dragWindow protected [BasicToolBarUI.DragWindow](../../../../javax/swing/plaf/basic/BasicToolBarUI.DragWindow.html "class in javax.swing.plaf.basic") dragWindow * #### focusedCompIndex protected int focusedCompIndex * #### dockingColor protected [Color](../../../../java/awt/Color.html "class in java.awt") dockingColor * #### floatingColor protected [Color](../../../../java/awt/Color.html "class in java.awt") floatingColor * #### dockingBorderColor protected [Color](../../../../java/awt/Color.html "class in java.awt") dockingBorderColor * #### floatingBorderColor protected [Color](../../../../java/awt/Color.html "class in java.awt") floatingBorderColor * #### dockingListener protected [MouseInputListener](../../../../javax/swing/event/MouseInputListener.html "interface in javax.swing.event") dockingListener * #### propertyListener protected [PropertyChangeListener](../../../../java/beans/PropertyChangeListener.html "interface in java.beans") propertyListener * #### toolBarContListener protected [ContainerListener](../../../../java/awt/event/ContainerListener.html "interface in java.awt.event") toolBarContListener * #### toolBarFocusListener protected [FocusListener](../../../../java/awt/event/FocusListener.html "interface in java.awt.event") toolBarFocusListener * #### constraintBeforeFloating protected [String](../../../../java/lang/String.html "class in java.lang") constraintBeforeFloating * #### upKey [@Deprecated](../../../../java/lang/Deprecated.html "annotation in java.lang") protected [KeyStroke](../../../../javax/swing/KeyStroke.html "class in javax.swing") upKey Deprecated. 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. * #### downKey [@Deprecated](../../../../java/lang/Deprecated.html "annotation in java.lang") protected [KeyStroke](../../../../javax/swing/KeyStroke.html "class in javax.swing") downKey Deprecated. 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. * #### leftKey [@Deprecated](../../../../java/lang/Deprecated.html "annotation in java.lang") protected [KeyStroke](../../../../javax/swing/KeyStroke.html "class in javax.swing") leftKey Deprecated. 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. * #### rightKey [@Deprecated](../../../../java/lang/Deprecated.html "annotation in java.lang") protected [KeyStroke](../../../../javax/swing/KeyStroke.html "class in javax.swing") rightKey Deprecated. 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.
Constructor Detail
* #### BasicToolBarUI public BasicToolBarUI()
Method Detail
* #### createUI public static [ComponentUI](../../../../javax/swing/plaf/ComponentUI.html "class in javax.swing.plaf") createUI([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") c) * #### installUI public void installUI([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") c) 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. Overrides: `[installUI](../../../../javax/swing/plaf/ComponentUI.html#installUI-javax.swing.JComponent-)` in class `[ComponentUI](../../../../javax/swing/plaf/ComponentUI.html "class in javax.swing.plaf")` Parameters: `c` \- the component where this UI delegate is being installed See Also: [ComponentUI.uninstallUI(javax.swing.JComponent)](../../../../javax/swing/plaf/ComponentUI.html#uninstallUI-javax.swing.JComponent-), [JComponent.setUI(javax.swing.plaf.ComponentUI)](../../../../javax/swing/JComponent.html#setUI-javax.swing.plaf.ComponentUI-), [JComponent.updateUI()](../../../../javax/swing/JComponent.html#updateUI--) * #### uninstallUI public void uninstallUI([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") c) 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. Overrides: `[uninstallUI](../../../../javax/swing/plaf/ComponentUI.html#uninstallUI-javax.swing.JComponent-)` in class `[ComponentUI](../../../../javax/swing/plaf/ComponentUI.html "class in javax.swing.plaf")` Parameters: `c` \- the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components See Also: [ComponentUI.installUI(javax.swing.JComponent)](../../../../javax/swing/plaf/ComponentUI.html#installUI-javax.swing.JComponent-), [JComponent.updateUI()](../../../../javax/swing/JComponent.html#updateUI--) * #### installDefaults protected void installDefaults() * #### uninstallDefaults protected void uninstallDefaults() * #### installComponents protected void installComponents() * #### uninstallComponents protected void uninstallComponents() * #### installListeners protected void installListeners() * #### uninstallListeners protected void uninstallListeners() * #### installKeyboardActions protected void installKeyboardActions() * #### uninstallKeyboardActions protected void uninstallKeyboardActions() * #### navigateFocusedComp protected void navigateFocusedComp(int direction) * #### createRolloverBorder protected [Border](../../../../javax/swing/border/Border.html "interface in javax.swing.border") 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. Since: 1.4 * #### createNonRolloverBorder protected [Border](../../../../javax/swing/border/Border.html "interface in javax.swing.border") 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. Since: 1.4 * #### createFloatingFrame protected [JFrame](../../../../javax/swing/JFrame.html "class in javax.swing") createFloatingFrame([JToolBar](../../../../javax/swing/JToolBar.html "class in javax.swing") toolbar) No longer used, use BasicToolBarUI.createFloatingWindow(JToolBar) See Also: [createFloatingWindow(javax.swing.JToolBar)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createFloatingWindow-javax.swing.JToolBar-) * #### createFloatingWindow protected [RootPaneContainer](../../../../javax/swing/RootPaneContainer.html "interface in javax.swing") createFloatingWindow([JToolBar](../../../../javax/swing/JToolBar.html "class in javax.swing") toolbar) Creates a window which contains the toolbar after it has been dragged out from its container Returns: a `RootPaneContainer` object, containing the toolbar. Since: 1.4 * #### createDragWindow protected [BasicToolBarUI.DragWindow](../../../../javax/swing/plaf/basic/BasicToolBarUI.DragWindow.html "class in javax.swing.plaf.basic") createDragWindow([JToolBar](../../../../javax/swing/JToolBar.html "class in javax.swing") toolbar) * #### isRolloverBorders public boolean isRolloverBorders() Returns a flag to determine whether rollover button borders are enabled. Returns: true if rollover borders are enabled; false otherwise Since: 1.4 See Also: [setRolloverBorders(boolean)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setRolloverBorders-boolean-) * #### setRolloverBorders public void setRolloverBorders(boolean rollover) Sets the flag for enabling rollover borders on the toolbar and it will also install the appropriate border depending on the state of the flag. Parameters: `rollover` \- if true, rollover borders are installed. Otherwise non-rollover borders are installed Since: 1.4 See Also: [isRolloverBorders()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#isRolloverBorders--) * #### installRolloverBorders protected void installRolloverBorders([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") c) Installs rollover borders on all the child components of the JComponent. This is a convenience method to call `setBorderToRollover` for each child component. Parameters: `c` \- container which holds the child components (usually a JToolBar) Since: 1.4 See Also: [setBorderToRollover(java.awt.Component)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setBorderToRollover-java.awt.Component-) * #### installNonRolloverBorders protected void installNonRolloverBorders([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") 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. Parameters: `c` \- container which holds the child components (usually a JToolBar) Since: 1.4 See Also: [setBorderToNonRollover(java.awt.Component)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setBorderToNonRollover-java.awt.Component-) * #### installNormalBorders protected void installNormalBorders([JComponent](../../../../javax/swing/JComponent.html "class in javax.swing") 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. Parameters: `c` \- container which holds the child components (usually a JToolBar) Since: 1.4 See Also: [setBorderToNonRollover(java.awt.Component)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setBorderToNonRollover-java.awt.Component-) * #### setBorderToRollover protected void setBorderToRollover([Component](../../../../java/awt/Component.html "class in java.awt") c) Sets the border of the component to have a rollover border which was created by the [createRolloverBorder()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createRolloverBorder--) method. Parameters: `c` \- component which will have a rollover border installed Since: 1.4 See Also: [createRolloverBorder()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createRolloverBorder--) * #### getRolloverBorder protected [Border](../../../../javax/swing/border/Border.html "interface in javax.swing.border") getRolloverBorder([AbstractButton](../../../../javax/swing/AbstractButton.html "class in javax.swing") b) Returns a rollover border for the button. Parameters: `b` \- the button to calculate the rollover border for Returns: the rollover border Since: 1.6 See Also: [setBorderToRollover(java.awt.Component)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setBorderToRollover-java.awt.Component-) * #### setBorderToNonRollover protected void setBorderToNonRollover([Component](../../../../java/awt/Component.html "class in java.awt") c) Sets the border of the component to have a non-rollover border which was created by the [createNonRolloverBorder()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createNonRolloverBorder--) method. Parameters: `c` \- component which will have a non-rollover border installed Since: 1.4 See Also: [createNonRolloverBorder()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createNonRolloverBorder--) * #### getNonRolloverBorder protected [Border](../../../../javax/swing/border/Border.html "interface in javax.swing.border") getNonRolloverBorder([AbstractButton](../../../../javax/swing/AbstractButton.html "class in javax.swing") b) Returns a non-rollover border for the button. Parameters: `b` \- the button to calculate the non-rollover border for Returns: the non-rollover border Since: 1.6 See Also: [setBorderToNonRollover(java.awt.Component)](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#setBorderToNonRollover-java.awt.Component-) * #### setBorderToNormal protected void setBorderToNormal([Component](../../../../java/awt/Component.html "class in java.awt") 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. Parameters: `c` \- component which will have a normal border re-installed Since: 1.4 See Also: [createNonRolloverBorder()](../../../../javax/swing/plaf/basic/BasicToolBarUI.html#createNonRolloverBorder--) * #### setFloatingLocation public void setFloatingLocation(int x, int y) * #### isFloating public boolean isFloating() * #### setFloating public void setFloating(boolean b, [Point](../../../../java/awt/Point.html "class in java.awt") p) * #### setOrientation public void setOrientation(int orientation) * #### getDockingColor public [Color](../../../../java/awt/Color.html "class in java.awt") getDockingColor() Gets the color displayed when over a docking area * #### setDockingColor public void setDockingColor([Color](../../../../java/awt/Color.html "class in java.awt") c) Sets the color displayed when over a docking area * #### getFloatingColor public [Color](../../../../java/awt/Color.html "class in java.awt") getFloatingColor() Gets the color displayed when over a floating area * #### setFloatingColor public void setFloatingColor([Color](../../../../java/awt/Color.html "class in java.awt") c) Sets the color displayed when over a floating area * #### canDock public boolean canDock([Component](../../../../java/awt/Component.html "class in java.awt") c, [Point](../../../../java/awt/Point.html "class in java.awt") p) * #### dragTo protected void dragTo([Point](../../../../java/awt/Point.html "class in java.awt") position, [Point](../../../../java/awt/Point.html "class in java.awt") origin) * #### floatAt protected void floatAt([Point](../../../../java/awt/Point.html "class in java.awt") position, [Point](../../../../java/awt/Point.html "class in java.awt") origin) * #### createToolBarContListener protected [ContainerListener](../../../../java/awt/event/ContainerListener.html "interface in java.awt.event") createToolBarContListener() * #### createToolBarFocusListener protected [FocusListener](../../../../java/awt/event/FocusListener.html "interface in java.awt.event") createToolBarFocusListener() * #### createPropertyListener protected [PropertyChangeListener](../../../../java/beans/PropertyChangeListener.html "interface in java.beans") createPropertyListener() * #### createDockingListener protected [MouseInputListener](../../../../javax/swing/event/MouseInputListener.html "interface in javax.swing.event") createDockingListener() * #### createFrameListener protected [WindowListener](../../../../java/awt/event/WindowListener.html "interface in java.awt.event") createFrameListener() * #### paintDragWindow protected void paintDragWindow([Graphics](../../../../java/awt/Graphics.html "class in java.awt") g) Paints the contents of the window used for dragging. Parameters: `g` \- Graphics to paint to. Throws: `[NullPointerException](../../../../java/lang/NullPointerException.html "class in java.lang")` \- is `g` is null Since: 1.5
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.