javax.swing
Class JToolBar
- Accessible, ImageObserver, MenuContainer, Serializable, SwingConstants
JToolBar is a component that provides a toolbar to Swing programs. Users
can add buttons (or actions that will be represented by JButtons) as well
as other components to the JToolBar. JToolBars can be dragged in and out
of their parent components. If the JToolBar is dragged out of the parent,
then it will be displayed in its own RootPaneContainer. For dragging to
work properly, JToolBars need to be placed in a Container that has a
BorderLayout. That parent Container cannot have components in the NORTH,
EAST, SOUTH, or WEST components (that is not the JToolBar).
BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
JToolBar() - This method creates a new JToolBar object with horizontal orientation
and no name.
|
JToolBar(int orientation) - This method creates a new JToolBar with the given orientation and no
name.
|
JToolBar(String name) - This method creates a new JToolBar object with the given name and
horizontal orientation.
|
JToolBar(String name, int orientation) - This method creates a new JToolBar object with the given name and
orientation.
|
JButton | add(Action action) - This method adds a new JButton that performs the given Action to the
JToolBar.
|
protected void | addImpl(Component component, Object constraints, int index) - This method overrides Container's addImpl method.
|
void | addSeparator() - This method adds a Separator of default size to the JToolBar.
|
void | addSeparator(Dimension size) - This method adds a Separator with the given size to the JToolBar.
|
protected PropertyChangeListener | createActionChangeListener(JButton button) - This method creates a pre-configured PropertyChangeListener which updates
the control as changes are made to the Action.
|
protected JButton | createActionComponent(Action action) - This method is used to create JButtons which can be added to the JToolBar
for the given action.
|
AccessibleContext | getAccessibleContext() - Returns the object that provides accessibility features for this
JToolBar component.
|
Component | getComponentAtIndex(int index) - This method returns the component at the given index.
|
int | getComponentIndex(Component component) - This method returns the index of the given component.
|
Insets | getMargin() - This method returns the margin property.
|
int | getOrientation() - This method returns the orientation of the JToolBar.
|
ToolBarUI | getUI() - This method returns the UI class used to paint this JToolBar.
|
String | getUIClassID() - This method returns the String identifier for the UI class to the used
with the JToolBar.
|
boolean | isBorderPainted() - This method returns the borderPainted property.
|
boolean | isFloatable() - This method returns the floatable property.
|
boolean | isRollover() - This method returns the rollover property.
|
protected void | paintBorder(Graphics graphics) - This method paints the border if the borderPainted property is true.
|
protected String | paramString() - Returns a string describing the attributes for the
JToolBar
component, for use in debugging.
|
void | setBorderPainted(boolean painted) - This method sets the borderPainted property.
|
void | setFloatable(boolean floatable) - This method sets the floatable property.
|
void | setLayout(LayoutManager mgr) - This method sets the layout manager to be used with the JToolBar.
|
void | setMargin(Insets margin) - This method sets the margin property.
|
void | setOrientation(int orientation) - This method sets the orientation property for JToolBar.
|
void | setRollover(boolean b) - This method sets the rollover property for the JToolBar.
|
void | setUI(ToolBarUI ui) - This method sets the UI used with the JToolBar.
|
void | updateUI() - This method resets the UI used to the Look and Feel defaults.
|
addAncestorListener , addNotify , addVetoableChangeListener , computeVisibleRect , contains , createToolTip , disable , enable , extends EventListener> T[] getListeners , firePropertyChange , firePropertyChange , fireVetoableChange , getAccessibleContext , getActionForKeyStroke , getActionMap , getAlignmentX , getAlignmentY , getAncestorListeners , getAutoscrolls , getBorder , getBounds , getClientProperty , getComponentGraphics , getComponentPopupMenu , getConditionForKeyStroke , getDebugGraphicsOptions , getDefaultLocale , getGraphics , getHeight , getInheritsPopupMenu , getInputMap , getInputMap , getInputVerifier , getInsets , getInsets , getLocation , getMaximumSize , getMinimumSize , getNextFocusableComponent , getPreferredSize , getRegisteredKeyStrokes , getRootPane , getSize , getToolTipLocation , getToolTipText , getToolTipText , getTopLevelAncestor , getTransferHandler , getUIClassID , getVerifyInputWhenFocusTarget , getVetoableChangeListeners , getVisibleRect , getWidth , getX , getY , grabFocus , isDoubleBuffered , isLightweightComponent , isManagingFocus , isOpaque , isOptimizedDrawingEnabled , isPaintingTile , isRequestFocusEnabled , isValidateRoot , paint , paintBorder , paintChildren , paintComponent , paintImmediately , paintImmediately , paramString , print , printAll , printBorder , printChildren , printComponent , processComponentKeyEvent , processKeyBinding , processKeyEvent , processMouseMotionEvent , putClientProperty , registerKeyboardAction , registerKeyboardAction , removeAncestorListener , removeNotify , removeVetoableChangeListener , repaint , repaint , requestDefaultFocus , requestFocus , requestFocus , requestFocusInWindow , requestFocusInWindow , resetKeyboardActions , reshape , revalidate , scrollRectToVisible , setActionMap , setAlignmentX , setAlignmentY , setAutoscrolls , setBackground , setBorder , setComponentPopupMenu , setDebugGraphicsOptions , setDefaultLocale , setDoubleBuffered , setEnabled , setFont , setForeground , setInheritsPopupMenu , setInputMap , setInputVerifier , setNextFocusableComponent , setOpaque , setRequestFocusEnabled , setToolTipText , setTransferHandler , setUI , setVerifyInputWhenFocusTarget , setVisible , unregisterKeyboardAction , update , updateUI |
add , add , add , add , add , addContainerListener , addImpl , addNotify , addPropertyChangeListener , addPropertyChangeListener , applyComponentOrientation , areFocusTraversalKeysSet , countComponents , deliverEvent , doLayout , extends EventListener> T[] getListeners , findComponentAt , findComponentAt , getAlignmentX , getAlignmentY , getComponent , getComponentAt , getComponentAt , getComponentCount , getComponentZOrder , getComponents , getContainerListeners , getFocusTraversalKeys , getFocusTraversalPolicy , getInsets , getLayout , getMaximumSize , getMinimumSize , getPreferredSize , insets , invalidate , isAncestorOf , isFocusCycleRoot , isFocusCycleRoot , isFocusTraversalPolicyProvider , isFocusTraversalPolicySet , layout , list , list , locate , minimumSize , paint , paintComponents , paramString , preferredSize , print , printComponents , processContainerEvent , processEvent , remove , remove , removeAll , removeContainerListener , removeNotify , setComponentZOrder , setFocusCycleRoot , setFocusTraversalKeys , setFocusTraversalPolicy , setFocusTraversalPolicyProvider , setFont , setLayout , transferFocusDownCycle , update , validate , validateTree |
action , add , addComponentListener , addFocusListener , addHierarchyBoundsListener , addHierarchyListener , addInputMethodListener , addKeyListener , addMouseListener , addMouseMotionListener , addMouseWheelListener , addNotify , addPropertyChangeListener , addPropertyChangeListener , applyComponentOrientation , areFocusTraversalKeysSet , bounds , checkImage , checkImage , coalesceEvents , contains , contains , createImage , createImage , createVolatileImage , createVolatileImage , deliverEvent , disable , disableEvents , dispatchEvent , doLayout , enable , enable , enableEvents , enableInputMethods , extends EventListener> T[] getListeners , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , getAccessibleContext , getAlignmentX , getAlignmentY , getBackground , getBounds , getBounds , getColorModel , getComponentAt , getComponentAt , getComponentListeners , getComponentOrientation , getCursor , getDropTarget , getFocusCycleRootAncestor , getFocusListeners , getFocusTraversalKeys , getFocusTraversalKeysEnabled , getFont , getFontMetrics , getForeground , getGraphics , getGraphicsConfiguration , getHeight , getHierarchyBoundsListeners , getHierarchyListeners , getIgnoreRepaint , getInputContext , getInputMethodListeners , getInputMethodRequests , getKeyListeners , getLocale , getLocation , getLocation , getLocationOnScreen , getMaximumSize , getMinimumSize , getMouseListeners , getMouseMotionListeners , getMouseWheelListeners , getName , getParent , getPeer , getPreferredSize , getPropertyChangeListeners , getPropertyChangeListeners , getSize , getSize , getToolkit , getTreeLock , getWidth , getX , getY , gotFocus , handleEvent , hasFocus , hide , imageUpdate , inside , invalidate , isBackgroundSet , isCursorSet , isDisplayable , isDoubleBuffered , isEnabled , isFocusCycleRoot , isFocusOwner , isFocusTraversable , isFocusable , isFontSet , isForegroundSet , isLightweight , isMaximumSizeSet , isMinimumSizeSet , isOpaque , isPreferredSizeSet , isShowing , isValid , isVisible , keyDown , keyUp , layout , list , list , list , list , list , locate , location , lostFocus , minimumSize , mouseDown , mouseDrag , mouseEnter , mouseExit , mouseMove , mouseUp , move , nextFocus , paint , paintAll , paramString , postEvent , preferredSize , prepareImage , prepareImage , print , printAll , processComponentEvent , processEvent , processFocusEvent , processHierarchyBoundsEvent , processHierarchyEvent , processInputMethodEvent , processKeyEvent , processMouseEvent , processMouseMotionEvent , processMouseWheelEvent , remove , removeComponentListener , removeFocusListener , removeHierarchyBoundsListener , removeHierarchyListener , removeInputMethodListener , removeKeyListener , removeMouseListener , removeMouseMotionListener , removeMouseWheelListener , removeNotify , removePropertyChangeListener , removePropertyChangeListener , repaint , repaint , repaint , repaint , requestFocus , requestFocus , requestFocusInWindow , requestFocusInWindow , reshape , resize , resize , setBackground , setBounds , setBounds , setComponentOrientation , setCursor , setDropTarget , setEnabled , setFocusTraversalKeys , setFocusTraversalKeysEnabled , setFocusable , setFont , setForeground , setIgnoreRepaint , setLocale , setLocation , setLocation , setMaximumSize , setMinimumSize , setName , setPreferredSize , setSize , setSize , setVisible , show , show , size , toString , transferFocus , transferFocusBackward , transferFocusUpCycle , update , validate |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
JToolBar
public JToolBar()
This method creates a new JToolBar object with horizontal orientation
and no name.
JToolBar
public JToolBar(int orientation)
This method creates a new JToolBar with the given orientation and no
name.
orientation
- JToolBar orientation (HORIZONTAL or VERTICAL)
JToolBar
public JToolBar(String name)
This method creates a new JToolBar object with the given name and
horizontal orientation.
name
- Name assigned to undocked tool bar.
JToolBar
public JToolBar(String name,
int orientation)
This method creates a new JToolBar object with the given name and
orientation.
name
- Name assigned to undocked tool bar.orientation
- JToolBar orientation (HORIZONTAL or VERTICAL)
add
public JButton add(Action action)
This method adds a new JButton that performs the given Action to the
JToolBar.
action
- The Action to add to the JToolBar.
- The JButton that wraps the Action.
addImpl
protected void addImpl(Component component,
Object constraints,
int index)
This method overrides Container's addImpl method. If a JButton is added,
it is disabled.
- addImpl in interface Container
component
- The Component to add.constraints
- The Constraints placed on the component.index
- The index to place the Component at.
addSeparator
public void addSeparator()
This method adds a Separator of default size to the JToolBar.
addSeparator
public void addSeparator(Dimension size)
This method adds a Separator with the given size to the JToolBar.
size
- The size of the Separator.
createActionChangeListener
protected PropertyChangeListener createActionChangeListener(JButton button)
This method creates a pre-configured PropertyChangeListener which updates
the control as changes are made to the Action. However, this is no
longer the recommended way of adding Actions to Containers. As such,
this method returns null.
button
- The JButton to configure a PropertyChangeListener for.
createActionComponent
protected JButton createActionComponent(Action action)
This method is used to create JButtons which can be added to the JToolBar
for the given action.
action
- The action to create a JButton for.
- The JButton created from the action.
getComponentAtIndex
public Component getComponentAtIndex(int index)
This method returns the component at the given index.
index
- The index of the component.
- The component at the given index.
getComponentIndex
public int getComponentIndex(Component component)
This method returns the index of the given component.
component
- The component to find.
- The index of the given component.
getMargin
public Insets getMargin()
This method returns the margin property.
getOrientation
public int getOrientation()
This method returns the orientation of the JToolBar.
- The orientation of the JToolBar.
getUI
public ToolBarUI getUI()
This method returns the UI class used to paint this JToolBar.
- The UI class for this JToolBar.
getUIClassID
public String getUIClassID()
This method returns the String identifier for the UI class to the used
with the JToolBar.
- getUIClassID in interface JComponent
- The String identifier for the UI class.
isBorderPainted
public boolean isBorderPainted()
This method returns the borderPainted property.
- The borderPainted property.
isFloatable
public boolean isFloatable()
This method returns the floatable property.
isRollover
public boolean isRollover()
This method returns the rollover property.
paintBorder
protected void paintBorder(Graphics graphics)
This method paints the border if the borderPainted property is true.
- paintBorder in interface JComponent
graphics
- The graphics object to paint with.
paramString
protected String paramString()
Returns a string describing the attributes for the JToolBar
component, for use in debugging. The return value is guaranteed to be
non-null
, but the format of the string may vary between
implementations.
- paramString in interface JComponent
- A string describing the attributes of the
JToolBar
.
setBorderPainted
public void setBorderPainted(boolean painted)
This method sets the borderPainted property. If set to false, the border
will not be painted.
painted
- Whether the border will be painted.
setFloatable
public void setFloatable(boolean floatable)
This method sets the floatable property. If set to false, the JToolBar
cannot be dragged.
floatable
- Whether the JToolBar can be dragged.
setMargin
public void setMargin(Insets margin)
This method sets the margin property. The margin property determines the
extra space between the children components of the JToolBar and the
border.
margin
- The margin property.
setOrientation
public void setOrientation(int orientation)
This method sets the orientation property for JToolBar.
orientation
- The new orientation for JToolBar.
setRollover
public void setRollover(boolean b)
This method sets the rollover property for the JToolBar. In rollover
mode, JButtons inside the JToolBar will only display their borders when
the mouse is moving over them.
b
- The new rollover property.
setUI
public void setUI(ToolBarUI ui)
This method sets the UI used with the JToolBar.
ui
- The UI used with the JToolBar.
JToolBar.java --
Copyright (C) 2002, 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.