Class JMTToolBar
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JToolBar
jmt.framework.gui.components.JMTToolBar
- All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, SwingConstants
- Direct Known Subclasses:
ComponentBar
Name: JMTToolbar
Description: A generic toolbar with many enhancements to be used by JMT. Image name can be stored inside Action or explicitly inserted. Pressed, rollover and selected (toggled) buttons requires images with the appropriate suffixes.
Date: 30/gen/07 Time: 10:44:05
- Version:
- 1.0
- Author:
- Bertoli Marco
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classInner class used to store buttons together with their button group (if any)Nested classes/interfaces inherited from class JToolBar
JToolBar.AccessibleJToolBar, JToolBar.SeparatorNested classes/interfaces inherited from class JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap<Integer, JMTButtonGroup> A map with all button groups with associated groupprotected HashMap<Action, JMTToolBar.ButtonWithGroup> A map with all buttons with associated component and groupsprotected ImageLoaderComponent used to load imagesFields inherited from class JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a new button to this toolbar.addButton(AbstractJMTAction action) Adds a new button to this toolbar.addGenericButton(AbstractJMTAction action) Adds a button deriving all properties from specified actionvoidaddToggleButton(AbstractJMTAction action) Adds a new button toggle to this toolbar.addToggleButton(AbstractJMTAction action, int group) Adds a new button toggle to this toolbar.addToggleButton(AbstractJMTAction action, String iconName) Adds a new button toggle to this toolbar.addToggleButton(AbstractJMTAction action, String iconName, int group) Adds a new button toggle to this toolbar.voidclearButtonGroupSelection(int group) Clears selection of a button groupvoidclickButton(AbstractJMTAction action) Clicks a given buttonvoidenableButtonGroup(int group, boolean value) Enables or disables every button of a button groupvoidenableButtons(boolean enable) Enables or disables all buttons of this toolbarReturns all buttons inside this toolbargetButton(AbstractJMTAction action) Returns a button, given its namegetButtonGroup(int group) Returns a button groupprotected JMTButtonGroupgetOrCreateGroup(int group) Returns a button group if present, otherwise creates and adds it.populateToolbar(Collection<AbstractJMTAction> abstractJMTactions) Populates this toolbar reading all properties from specified actions.populateToolbar(AbstractJMTAction[] abstractJMTactions) Populates this toolbar reading all properties from specified actions.removeButton(AbstractJMTAction action) Removes any type of button (including toggle ones) from this toolbarMethods inherited from class JToolBar
add, addImpl, addSeparator, createActionChangeListener, createActionComponent, getAccessibleContext, getComponentAtIndex, getComponentIndex, getMargin, getOrientation, getUI, getUIClassID, isBorderPainted, isFloatable, isRollover, paintBorder, paramString, setBorderPainted, setFloatable, setLayout, setMargin, setOrientation, setRollover, setUI, updateUIMethods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
imageLoader
Component used to load images -
buttons
A map with all buttons with associated component and groups -
buttonGroups
A map with all button groups with associated group
-
-
Constructor Details
-
JMTToolBar
Builds a new toolbar- Parameters:
loader- component used to load images
-
-
Method Details
-
addButton
Adds a new button to this toolbar.- Parameters:
action- action associated to the buttoniconName- image to be displayed on the button. If null the image from the action is used. If this is reset too, the name is displayed.- Returns:
- created button
-
addButton
Adds a new button to this toolbar.- Parameters:
action- action associated to the button- Returns:
- created button
-
addToggleButton
Adds a new button toggle to this toolbar.- Parameters:
action- action associated to the buttoniconName- image to be displayed on the button. If null the image from the action is used. If this is reset too, the name is displayed.group- identifier of button group. Each button belonging to the same group cannot be pressed together. Groups are created here, if group is less than zero means no grouping.- Returns:
- created button
-
addToggleButton
Adds a new button toggle to this toolbar. This button has no group.- Parameters:
action- action associated to the buttoniconName- image to be displayed on the button. If null the image from the action is used. If this is reset too, the name is displayed.- Returns:
- created button
-
addToggleButton
Adds a new button toggle to this toolbar.- Parameters:
action- action associated to the buttongroup- identifier of button group. Each button belonging to the same group cannot be pressed together. Groups are created here, if group is less than zero means no grouping.- Returns:
- created button
-
addToggleButton
Adds a new button toggle to this toolbar. This button has no group.- Parameters:
action- action associated to the button- Returns:
- created button
-
addGenericButton
Adds a button deriving all properties from specified action- Parameters:
action- action associated to the button- Returns:
- created button
-
removeButton
Removes any type of button (including toggle ones) from this toolbar- Parameters:
action- action of the button to be removed- Returns:
- removed button
-
addSeparator
public void addSeparator()- Overrides:
addSeparatorin classJToolBar
-
getButtonGroup
Returns a button group- Parameters:
group- identifier of button group- Returns:
- the button group or null if it does not exists
-
getButton
Returns a button, given its name- Parameters:
action- action of the button to be returned- Returns:
- found button
-
enableButtonGroup
public void enableButtonGroup(int group, boolean value) Enables or disables every button of a button group- Parameters:
group- group to be enabled or disabledvalue- true to enable the group, false to disable it.
-
clearButtonGroupSelection
public void clearButtonGroupSelection(int group) Clears selection of a button group- Parameters:
group- group to be deselected
-
clickButton
Clicks a given button- Parameters:
action- action of the button to be clicked
-
getAllButtons
Returns all buttons inside this toolbar- Returns:
- a set with all buttons
-
enableButtons
public void enableButtons(boolean enable) Enables or disables all buttons of this toolbar- Parameters:
enable- true to enable every button, false to disable them
-
populateToolbar
Populates this toolbar reading all properties from specified actions. null values are used to add a separator.- Parameters:
abstractJMTactions- a collection of AbstractJMTAction with all actions to be added- Returns:
- an ArrayList with all added objects (each element is instanceof AbstractButton)
- See Also:
-
populateToolbar
Populates this toolbar reading all properties from specified actions. null values are used to add a separator.- Parameters:
abstractJMTactions- an array of AbstractJMTAction with all actions to be added- Returns:
- an ArrayList with all added objects (each element is instanceof AbstractButton)
- See Also:
-
getOrCreateGroup
Returns a button group if present, otherwise creates and adds it.- Parameters:
group- group to be get- Returns:
- created group
-