com.quadrique.jbuildingblocks.gui
Class ToolBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JToolBar
                  extended by com.quadrique.jbuildingblocks.gui.ToolBar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants

public class ToolBar
extends JToolBar

This class implements a generic tool bar.

A typical usage is to create a sub-class and to populate the toolbar from that sub-class as shown below:
...
public MainWindowToolBar(Actions zActions) throws Exception
{
super(false);
add(zActions.get(ActionFileNew.CLASS_NAME));
add(zActions.get(ActionFileOpen.CLASS_NAME));
add(zActions.get(ActionFileSave.CLASS_NAME));
addSeparator();
add(zActions.get(ActionFilePrint.CLASS_NAME));
addSeparator();
add(zActions.get(ActionEditCut.CLASS_NAME));
add(zActions.get(ActionEditCopy.CLASS_NAME));
add(zActions.get(ActionEditPaste.CLASS_NAME));
addSeparator();
add(zActions.get(ActionViewDomainPanel.CLASS_NAME));
add(zActions.get(ActionViewDesktopPanel.CLASS_NAME));
add(zActions.get(ActionViewRefresh.CLASS_NAME));
addSeparator();
add(zActions.get(ActionHelpContents.CLASS_NAME));
add(zActions.get(ActionHelpWhatIsThis.CLASS_NAME));
}
...

Author:
Hervé Rivere
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JToolBar
JToolBar.Separator
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ToolBar(boolean zIsFloatable)
          Constructor
ToolBar(boolean zIsFloatable, int zOrientation)
          Constructor
 
Method Summary
 JButton add(Action zAction)
          Add an action to the toolbar.
 JButton add(ActionBase zAction)
          Add an action to the toolbar.
 void add(ActionBase[] zActions)
          Add the actions associated to the toolbar
 void addHelpContentsItem(String zItemToolTipText, String zItemIconFileName)
          To add a HelpContents button i.e.
 void addHelpWhatIsThisItem(String zItemToolTipText, String zItemIconFileName)
          To add a "Help What's This" button i.e.
 void addSeparator(boolean zUseIcon)
          Add a separator to the toolbar
 
Methods inherited from class javax.swing.JToolBar
addSeparator, addSeparator, getAccessibleContext, getComponentAtIndex, getComponentIndex, getMargin, getOrientation, getUI, getUIClassID, isBorderPainted, isFloatable, isRollover, setBorderPainted, setFloatable, setLayout, setMargin, setOrientation, setRollover, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToolBar

public ToolBar(boolean zIsFloatable)
Constructor

Parameters:
zIsFloatable - true if the toolbar is floatable

ToolBar

public ToolBar(boolean zIsFloatable,
               int zOrientation)
Constructor

Parameters:
zIsFloatable - true if the toolbar is floatable
zOrientation - JToolBar.HORIZONTAL or JToolBar.VERTICAL
Method Detail

add

public JButton add(ActionBase zAction)
Add an action to the toolbar.

Parameters:
zAction - the action
Returns:
null if the opeartion did not work, the newly created JButton instance otherwise
See Also:
ActionBase

add

public JButton add(Action zAction)
Add an action to the toolbar. The action SHORT_DESCRIPTION property is used for the tooltip text

Overrides:
add in class JToolBar
Parameters:
zAction - the action
Returns:
null if the opeartion did not work, the newly created JButton instance otherwise
Throws:
Exception - if an error occurs

addSeparator

public void addSeparator(boolean zUseIcon)
Add a separator to the toolbar


addHelpContentsItem

public void addHelpContentsItem(String zItemToolTipText,
                                String zItemIconFileName)
                         throws Exception
To add a HelpContents button i.e. a button that triggers the display of the online help upon activation

Parameters:
zItemToolTipText - the tooltip text
zItemIconFileName - the icon file name
Throws:
Exception - if an error occurs

addHelpWhatIsThisItem

public void addHelpWhatIsThisItem(String zItemToolTipText,
                                  String zItemIconFileName)
                           throws Exception
To add a "Help What's This" button i.e. a button that triggers the context sensitive cursor. Once the user clicks on a component, the online help window is shown and the topic asociated to the component is shown

Parameters:
zItemToolTipText - the tooltip text
zItemIconFileName - the icon file name
Throws:
Exception - if an error occurs

add

public void add(ActionBase[] zActions)
         throws Exception
Add the actions associated to the toolbar

Parameters:
zActions - an array that contains the toolbar actions. In order to add a separator, simply use a "null" entry in the array. For instance, the following sample classLoader sets up an array for a toolbar with 4 actions and a separator between the save and print action:
...
super(false);
ActionBase lToolbarActions[] = new ActionBase[] {
zActions.get(ActionFileNew.CLASS_NAME),
zActions.get(ActionFileOpen.CLASS_NAME),
zActions.get(ActionFileSave.CLASS_NAME),
null,
zActions.get(ActionFilePrint.CLASS_NAME),
null,
zActions.get(ActionEditCut.CLASS_NAME),
zActions.get(ActionEditCopy.CLASS_NAME),
zActions.get(ActionEditPaste.CLASS_NAME),
null,
zActions.get(ActionViewDomainPanel.CLASS_NAME),
zActions.get(ActionViewDesktopPanel.CLASS_NAME),
zActions.get(ActionViewRefresh.CLASS_NAME),
null,
zActions.get(ActionHelpContents.CLASS_NAME),
zActions.get(ActionHelpWhatIsThis.CLASS_NAME),
};
super.add(lToolbarActions);
...
Throws:
Exception - if an error occurs


Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.