Home about services products contact login
   com.smardec.asc

Advanced Swing Components

  animatepanel
  autocomplete
  dropdown
  filechooser
  fontchooser
  gradient
  hyperlink
  outlookpanel
  outlookpanel.renderers
  quick
  rotate
  sliderpanel
  spantable
  splashscreen
  statusbar
  table
  table.renderers
  table.wrappers
  tree
  treetable
  util
  xmlbars
  xmlbars.menubar
  xmlbars.toolbar
  xmlbars.toolbar.layouts
com.smardec.asc.dropdown
Class JDropDownButton

java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.AbstractButton
|
+--javax.swing.JButton
|
+--com.smardec.asc.dropdown.JDropDownButton
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants

public class JDropDownButton
extends javax.swing.JButton

JDropDownButton is a Swing component based on JButton that provides popup menu with alternate actions.


Field Summary
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
JDropDownButton()
Constructs a drop-down button with no actions.
JDropDownButton(boolean toolbarStyle)
Constructs a drop-down button with no actions.
JDropDownButton(java.util.Vector actions)
Constructs a drop-down button with specified actions.
JDropDownButton(java.util.Vector actions, boolean toolbarStyle)
Constructs a drop-down button with specified actions.
Method Summary
void addAction(javax.swing.Action a)
Appends the specified action to the end of this drop-down button.
void addAction(int index, javax.swing.Action a)
Inserts the specified action at the specified position in this drop-down button.
int getActionsCount()
Returns the number of actions in the drop-down button.
javax.swing.Action getActiveAction()
Returns active action or null if drop-down button has no actions.
int getDropDownAreaWidth()
Retruns the width of drop area in this drop-down button.
javax.swing.ImageIcon getDropDownIcon()
Retruns the drop-down icon in this drop-down button.
java.awt.Dimension getPreferredSize()
Returns preferred size of this drop-down button.
int indexOf(javax.swing.Action a)
Searches for the specified action, testing for equality using the equals method.
boolean isChangeActiveAction()
Indicates whether drop-down button should change active action (action that is displayed on the button).
boolean isShowText()
Indicates whether drop-down button shows its text.
boolean isUseFixedPreferredSize()
Indicates whether drop-down button should use fixed preferred size.
boolean removeAction(javax.swing.Action a)
Removes specified action from the drop-down button.
javax.swing.Action removeAction(int index)
Removes the action at the specified position in the drop-down button.
void setActiveAction(int index)
Specifies the active action index.
void setChangeActiveAction(boolean changeActiveAction)
Specifies whether drop-down button should change active action (action that is displayed on the button).
void setDropDownAreaWidth(int dropDownAreaWidth)
Specifies the width of drop area in this drop-down button.
void setDropDownIcon(javax.swing.ImageIcon dropDownIcon)
Specifies the drop-down icon in this drop-down button.
void setPreferredSize(java.awt.Dimension preferredSize)
Specifies preferred size of this drop-down button.
void setShowText(boolean showText)
Specifies whether drop-down button shows its text.
void setUseFixedPreferredSize(boolean useFixedPreferredSize)
Specifies whether drop-down button should use fixed preferred size.
Methods inherited from class javax.swing.JButton
configurePropertiesFromAction, getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable, updateUI
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addItemListener, checkHorizontalKey, checkVerticalKey, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, 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, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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

Constructor Detail
JDropDownButton
public JDropDownButton()

Constructs a drop-down button with no actions.


JDropDownButton
public JDropDownButton(boolean toolbarStyle)
Constructs a drop-down button with no actions.

Parameters:
toolbarStyle - if true constructs toolbar style button, false otherwise

JDropDownButton
public JDropDownButton(java.util.Vector actions) throws java.lang.Exception
Constructs a drop-down button with specified actions.

Parameters:
actions - alternate actions for JDropDownButton
Throws:
java.lang.Exception - actions contains object than is not 'javax.swing.Action'

JDropDownButton
public JDropDownButton(java.util.Vector actions, boolean toolbarStyle) throws java.lang.Exception
Constructs a drop-down button with specified actions.

Parameters:
actions - alternate actions for JDropDownButton
toolbarStyle - if true constructs toolbar style button, false otherwise
Throws:
java.lang.Exception - actions contains object than is not 'javax.swing.Action'
Method Detail
addAction
public void addAction(javax.swing.Action a)
Appends the specified action to the end of this drop-down button.

Parameters:
a - action to be appended to this JAnimatePanel

addAction
public void addAction(int index, javax.swing.Action a) throws java.lang.ArrayIndexOutOfBoundsException
Inserts the specified action at the specified position in this drop-down button. Shifts the action currently at that position (if any) and any subsequent actions to the bottom (adds one to their indices).

Parameters:
index - index at which the specified action is to be inserted
a - action to be inserted
Throws:
java.lang.ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index > getActionsCount()).

removeAction
public javax.swing.Action removeAction(int index) throws java.lang.ArrayIndexOutOfBoundsException
Removes the action at the specified position in the drop-down button. Shifts any subsequent actions to the top (subtracts one from their indices). Returns the action that was removed from the drop-down button.

Parameters:
index - the index of the tab to be removed
Returns:
the action that was removed from the JDropDownButton.
Throws:
java.lang.ArrayIndexOutOfBoundsException

removeAction
public boolean removeAction(javax.swing.Action a)
Removes specified action from the drop-down button. If the drop-down button does not contain the action, it is unchanged.

Parameters:
a - action to be removed
Returns:
true if the JDropDownButton contained the specified action.

indexOf
public int indexOf(javax.swing.Action a)
Searches for the specified action, testing for equality using the equals method.

Parameters:
a - action to search for
Returns:
the index of the action in the JDropDownButton;
returns -1 if the action is not found.

getActionsCount
public int getActionsCount()
Returns the number of actions in the drop-down button.

Returns:
the number of actions in the JDropDownButton.

getActiveAction
public javax.swing.Action getActiveAction()
Returns active action or null if drop-down button has no actions.

Returns:
active action or null if JDropDownButton has no actions.

setActiveAction
public void setActiveAction(int index) throws java.lang.ArrayIndexOutOfBoundsException
Specifies the active action index.

Parameters:
index - the index of action to set active
java.lang.ArrayIndexOutOfBoundsException

isShowText
public boolean isShowText()
Indicates whether drop-down button shows its text.
Note: Default value is true.

Returns:
true if the JDropDownButton shows its text, false otherwise.

setShowText
public void setShowText(boolean showText)
Specifies whether drop-down button shows its text.
Note: Default value is true.

Parameters:
showText - true to show text, false otherwise.

isChangeActiveAction
public boolean isChangeActiveAction()
Indicates whether drop-down button should change active action (action that is displayed on the button).
Note: Default value is true.

Returns:
true if JDropDownButton should change active action, false otherwise.

setChangeActiveAction
public void setChangeActiveAction(boolean changeActiveAction)
Specifies whether drop-down button should change active action (action that is displayed on the button).
Note: Default value is true.

Parameters:
changeActiveAction - if true JDropDownButton changes active action, false otherwise.

getDropDownAreaWidth
public int getDropDownAreaWidth()
Retruns the width of drop area in this drop-down button.

Returns:
the width of drop area in this JDropDownButton.

setDropDownAreaWidth
public void setDropDownAreaWidth(int dropDownAreaWidth)
Specifies the width of drop area in this drop-down button.

Parameters:
dropDownAreaWidth - width of drop area in this JDropDownButton.

getDropDownIcon
public javax.swing.ImageIcon getDropDownIcon()
Retruns the drop-down icon in this drop-down button.

Returns:
the drop-down icon in this JDropDownButton.

setDropDownIcon
public void setDropDownIcon(javax.swing.ImageIcon dropDownIcon)
Specifies the drop-down icon in this drop-down button.

Parameters:
dropDownIcon - drop-down icon in this JDropDownButton.

isUseFixedPreferredSize
public boolean isUseFixedPreferredSize()
Indicates whether drop-down button should use fixed preferred size.
If true getPreferredSize() returns the preferred size value that is not depend on which action is active. By default drop-down button queries all actions and returns maximum within all values.
If false getPreferredSize() returns the preferred size depending on active action.
Note: Default value is true.

Returns:
true if JDropDownButton should use fixed preferred size, false otherwise.
See Also:
setUseFixedPreferredSize(boolean), getPreferredSize(), setPreferredSize(java.awt.Dimension)

setUseFixedPreferredSize
public void setUseFixedPreferredSize(boolean useFixedPreferredSize)
Specifies whether drop-down button should use fixed preferred size.
If true getPreferredSize() returns the preferred size value that is not depend on which action is active. By default drop-down button queries all actions and returns maximum within all values.
If false getPreferredSize() returns the preferred size depending on active action.
Note: Default value is true.

Parameters:
useFixedPreferredSize - true if JDropDownButton should use fixed preferred size, false otherwise
See Also:
isUseFixedPreferredSize(), getPreferredSize(), setPreferredSize(java.awt.Dimension)

getPreferredSize
public java.awt.Dimension getPreferredSize()
Returns preferred size of this drop-down button.
If isUseFixedPreferredSize() is true this method returns the preferred size value that is not depend on which action is active. The default value is calculated in the following manner: drop-down button queries all actions and returns maximum within all values + dropDownAreaWidth.
If isUseFixedPreferredSize() is false this method returns the preferred size value depending on active action. The default value is calculated in the following manner: preferred size calculated on active action + dropDownAreaWidth.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
preferred size of this JDropDownButton.
See Also:
isUseFixedPreferredSize(), getDropDownAreaWidth()

setPreferredSize
public void setPreferredSize(java.awt.Dimension preferredSize)
Specifies preferred size of this drop-down button.

Overrides:
setPreferredSize in class javax.swing.JComponent
Parameters:
preferredSize - preferred size of this JDropDownButton
See Also:
getPreferredSize(), isUseFixedPreferredSize()
Home about services products contact login