com.levigo.util.swing
Class DropDownToggleButton

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by javax.swing.JToggleButton
                      extended by com.levigo.util.swing.action.NonUglyActionJToggleButton
                          extended by com.levigo.util.swing.DropDownToggleButton
All Implemented Interfaces:
GraphicsConfigurationValidateable, ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants

public class DropDownToggleButton
extends NonUglyActionJToggleButton

A DropDownButton is intended to be used in a toolbar as multiple action button.

It allows to add several actions, which are provided in popup menu to change this buttons action. At creation time this button will be wired with the first action it gets as sub menu action. A single click on this button fires the wired action. Each time a sub menu item action is clicked, this button will be wired with this selected action and a single on it fires this selected action. To work properly it is recommended to add sub menu items by a call of addMenuItemAction(Action).

To indicate that this button provides a sub set of different actions a small arrow will be displayed at the right bottom of the icon.

Author:
Carolin Koehler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.levigo.util.swing.action.NonUglyActionJToggleButton
NonUglyActionJToggleButton.AccessibleNonUglyActionJToggleButton
 
Nested classes/interfaces inherited from class javax.swing.JToggleButton
JToggleButton.AccessibleJToggleButton, JToggleButton.ToggleButtonModel
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 boolean popupIsVisible
           
 boolean popupShouldBeVisible
           
 
Fields inherited from class com.levigo.util.swing.action.NonUglyActionJToggleButton
isValidateGraphicsConfigurationEnabled, TOOLBAR_APPLICATION, TOOLBAR_MAINOFFICE, WITH_BORDER, WITHOUT_BORDER
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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
DropDownToggleButton()
          Construct this button
 
Method Summary
 JMenuItem addMenuItemAction(Action a)
          Appends a new menu item to the end of the menu which dispatches the specified Action object.
protected  void configurePropertiesFromAction(Action a)
          This event adds a functionality for the action parameter "checked"
 Icon getFallbackIcon()
          Gets the buttons fallback icon.
 String getFallbackToolTipText()
          Gets the buttons fallback tool tip text.
protected  void paintComponent(Graphics g)
           
 void setAction(Action a)
           
 void setEnabled(boolean b)
           
 void setFallbackIcon(Icon fallbackIcon)
          Sets the buttons fallback icon.
 void setFallbackToolTipText(String fallbackToolTipText)
          Sets the buttons fallback tooltip text.
 
Methods inherited from class com.levigo.util.swing.action.NonUglyActionJToggleButton
getAccessibleContext, getGraphicsConfiguration, initialize, isValidateGraphicsConfigurationEnabled, setBorder, setRolloverEnabled, setValidateGraphicsConfigurationEnabled
 
Methods inherited from class javax.swing.JToggleButton
getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.AbstractButton
actionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHideActionText, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, removeActionListener, removeChangeListener, removeItemListener, removeNotify, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class javax.swing.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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.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, 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, 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, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

popupIsVisible

public boolean popupIsVisible

popupShouldBeVisible

public boolean popupShouldBeVisible
Constructor Detail

DropDownToggleButton

@CallOnEDT
public DropDownToggleButton()
Construct this button

Method Detail

addMenuItemAction

@CallOnEDT
public JMenuItem addMenuItemAction(Action a)
Appends a new menu item to the end of the menu which dispatches the specified Action object.

Parameters:
a - the Action to add to the menu
Returns:
the new menu item
See Also:
Action

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action a)
Description copied from class: NonUglyActionJToggleButton
This event adds a functionality for the action parameter "checked"

Overrides:
configurePropertiesFromAction in class NonUglyActionJToggleButton
See Also:
AbstractButton.configurePropertiesFromAction(javax.swing.Action)

paintComponent

protected void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent
See Also:
JComponent.paintComponent(java.awt.Graphics)

getFallbackIcon

@CallOnEDT
public Icon getFallbackIcon()
Gets the buttons fallback icon. This icon is used if the chosen sub action ToolTipText no icon .

Returns:
fallbackIcon the icon used as the fallback image if the chosen menu item action provides no icon resource.

getFallbackToolTipText

@CallOnEDT
public String getFallbackToolTipText()
Gets the buttons fallback tool tip text. This text is used if the chosen sub action provides no tool tip text .

Returns:
fallbackIcon the icon used as the fallback image if the chosen menu item action provides no icon resource.

setAction

@CallOnEDT
public void setAction(Action a)
Overrides:
setAction in class AbstractButton
See Also:
AbstractButton.setAction(javax.swing.Action)

setEnabled

@CallOnEDT
public void setEnabled(boolean b)
Overrides:
setEnabled in class AbstractButton
See Also:
AbstractButton.setEnabled(boolean)

setFallbackIcon

@CallOnEDT
public void setFallbackIcon(Icon fallbackIcon)
Sets the buttons fallback icon. This icon is used if the chosen sub action ToolTipText no icon .

Parameters:
fallbackIcon - the icon used as the fallback image if the chosen menu item action provides no icon resource.

setFallbackToolTipText

@CallOnEDT
public void setFallbackToolTipText(String fallbackToolTipText)
Sets the buttons fallback tooltip text. This tool tip text is used if the chosen sub action provides no tooltip text .

Parameters:
fallbackToolTipText - the text used as the fallback tool tip text if the chosen menu item action provides no tool tip text.


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.