public class JDropDownButton extends JButton
| Modifier and Type | Class and Description |
|---|---|
protected class |
JDropDownButton.WinListener
A listener class that watches for a popup window closing.
|
JButton.AccessibleJButtonAbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListenerJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected JDropDownButton.WinListener |
popupListener
The window-closing listener for the popup.
|
protected List<ActionListener> |
quickListeners |
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_PROPERTYlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JDropDownButton() |
JDropDownButton(Action a) |
JDropDownButton(Icon icon) |
JDropDownButton(String text) |
JDropDownButton(String text,
Icon icon) |
| Modifier and Type | Method and Description |
|---|---|
JMenuItem |
add(Action a)
Creates a new menu item attached to the specified
Action
object and appends it to the end of this menu. |
Component |
add(Component c)
Appends a component to the end of this menu.
|
Component |
add(Component c,
int index)
Adds the specified component to this container at the given position.
|
JMenuItem |
add(JMenuItem menuItem)
Appends a menu item to the end of this menu.
|
JMenuItem |
add(String s)
Creates a new menu item with the specified text and appends it to the end
of this menu.
|
void |
addMenuListener(MenuListener l)
Adds a listener for menu events.
|
void |
addQuickActionListener(ActionListener listener) |
void |
addSeparator()
Appends a new separator to the end of the menu.
|
protected PropertyChangeListener |
createActionChangeListener(JMenuItem b)
Returns a properly configured
PropertyChangeListener which
updates the control as changes to the Action occur. |
protected JMenuItem |
createActionComponent(Action a)
Factory method which creates the
JMenuItem for
Actions added to the JMenu. |
protected JDropDownButton.WinListener |
createWinListener(JPopupMenu p)
Creates a window-closing listener for the popup.
|
void |
doClick(int pressTime)
Programmatically performs a "click".
|
protected void |
fireMenuCanceled()
Notifies all listeners that have registered interest for notification on
this event type.
|
protected void |
fireMenuDeselected()
Notifies all listeners that have registered interest for notification on
this event type.
|
protected void |
fireMenuSelected()
Notifies all listeners that have registered interest for notification on
this event type.
|
protected void |
fireQuickActionPerformed(ActionEvent event) |
Component |
getComponent()
Returns the
java.awt.Component used to paint this
MenuElement. |
int |
getDelay()
Returns the suggested delay, in milliseconds, before submenus are popped
up or down.
|
JMenuItem |
getItem(int pos)
Returns the
JMenuItem at the specified position. |
int |
getItemCount()
Returns the number of items on the menu, including separators.
|
Component |
getMenuComponent(int n)
Returns the component at position
n. |
int |
getMenuComponentCount()
Returns the number of components on the menu.
|
Component[] |
getMenuComponents()
Returns an array of
Components of the menu's subcomponents. |
MenuListener[] |
getMenuListeners()
Returns an array of all the
MenuListeners added to this
JMenu with addMenuListener(). |
JPopupMenu |
getPopupMenu()
Returns the popupmenu associated with this menu.
|
protected Point |
getPopupMenuOrigin()
Computes the origin for the
JMenu's popup menu. |
JPopupMenu |
getPopupMenuOrNull() |
int |
getPopupOrientation() |
int |
getQuickActionDelay() |
MenuElement[] |
getSubElements()
Returns an array of
MenuElements containing the submenu for
this menu component. |
JMenuItem |
getTreeMenuItemByActionCommand(String type) |
void |
hidePopup()
Causes the combo box to close its popup window.
|
JMenuItem |
insert(Action a,
int pos)
Inserts a new menu item attached to the specified
Action
object at a given position. |
JMenuItem |
insert(JMenuItem mi,
int pos)
Inserts the specified
JMenuitem at a given position. |
void |
insert(String s,
int pos)
Inserts a new menu item with the specified text at a given position.
|
void |
insertSeparator(int index)
Inserts a separator at the specified position.
|
protected void |
installAncestorListener() |
boolean |
isMenuComponent(Component c)
Returns true if the specified component exists in the submenu hierarchy.
|
boolean |
isPaintHandle() |
boolean |
isPopupMenuVisible()
Returns true if the menu's popup window is visible.
|
void |
menuSelectionChanged(boolean isIncluded)
Messaged when the menubar selection changes to activate or deactivate
this menu.
|
protected void |
paintComponent(Graphics g) |
void |
paintHandle(Graphics g) |
void |
paintTriangle(Graphics g,
int x,
int y,
int size,
int direction,
boolean isEnabled) |
void |
remove(Component c)
Removes the component
c from this menu. |
void |
remove(int pos)
Removes the menu item at the specified index from this menu.
|
void |
remove(JMenuItem item)
Removes the specified menu item from this menu.
|
void |
removeAll()
Removes all menu items from this menu.
|
void |
removeMenuListener(MenuListener l)
Removes a listener for menu events.
|
void |
removeQuickActionListener(ActionListener listener) |
void |
setDelay(int d)
Sets the suggested delay before the menu's
PopupMenu is
popped up or down. |
void |
setMenuLocation(int x,
int y)
Sets the location of the popup component.
|
JDropDownButton |
setPaintHandle(boolean paintHandle) |
void |
setPopupMenuVisible(boolean b)
Sets the visibility of the menu's popup.
|
void |
setPopupOrientation(int orientation) |
void |
setQuickActionDelay(int quickActionDelay) |
void |
updateUI() |
getAccessibleContext, getUIClassID, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapableactionPropertyChanged, addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, 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, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHideActionText, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPositionaddAncestorListener, 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, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, 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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeaction, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, transferFocusBackward, transferFocusUpCycleprotected List<ActionListener> quickListeners
protected JDropDownButton.WinListener popupListener
JDropDownButton.WinListenerpublic JDropDownButton()
public JDropDownButton(Action a)
public JDropDownButton(Icon icon)
public JDropDownButton(String text)
public int getQuickActionDelay()
public void setQuickActionDelay(int quickActionDelay)
public boolean isPaintHandle()
public JDropDownButton setPaintHandle(boolean paintHandle)
protected void installAncestorListener()
public void hidePopup()
public void addQuickActionListener(ActionListener listener)
public void removeQuickActionListener(ActionListener listener)
protected void fireQuickActionPerformed(ActionEvent event)
public int getPopupOrientation()
public void setPopupOrientation(int orientation)
orientation - : SwingConstants.LEFT or SwingConstants.RIGHTpublic void paintHandle(Graphics g)
protected void paintComponent(Graphics g)
paintComponent in class JComponentpublic void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled)
public boolean isPopupMenuVisible()
public void setPopupMenuVisible(boolean b)
b - a boolean value -- true to make the menu visible, false to hide
it @@beaninfo description: The popup menu's visibility expert: true
hidden: trueprotected Point getPopupMenuOrigin()
JMenu's popup menu. This method
uses Look and Feel properties named Menu.menuPopupOffsetX,
Menu.menuPopupOffsetY,
Menu.submenuPopupOffsetX, and
Menu.submenuPopupOffsetY to adjust the exact location of
popup.Point in the coordinate space of the menu which
should be used as the origin of the JMenu's popup menupublic int getDelay()
delay property. In most cases, the delay is
not observed for top level menus or while dragging. The default for
delay is 0. This method is a property of the look and feel
code and is used to manage the idiosyncracies of the various UI
implementations.delay propertypublic void setDelay(int d)
PopupMenu is
popped up or down. Each look and feel (L#F) may determine it's own
policy for observing the delay property. In most cases, the delay is not
observed for top level menus or while dragging. This method is a property
of the look and feel code and is used to manage the idiosyncracies of the
various UI implementations.d - the number of milliseconds to delayIllegalArgumentException - if d is less than 0 popup
menu visible expert: truepublic void setMenuLocation(int x,
int y)
x - the x coordinate of the popup's new positiony - the y coordinate of the popup's new positionpublic JMenuItem add(JMenuItem menuItem)
menuItem - the JMenuitem to be addedJMenuItem addedpublic Component add(Component c)
public Component add(Component c, int index)
index equals -1, the component will be appended to the end.add in class Containerc - the Component to addindex - the position at which to insert the componentComponent addedremove(int),
Container.add(Component, int)public void remove(int pos)
remove in class Containerpos - the position of the item to be removedIllegalArgumentException - if the value of pos < 0,
or if pos is greater than the number of menu itemspublic void remove(Component c)
c from this menu.public void removeAll()
public JMenuItem add(String s)
s - the string for the menu item to be addedpublic JMenuItem add(Action a)
Action
object and appends it to the end of this menu. As of 1.3, this is no
longer the preferred method for adding Actions to a
container. Instead it is recommended to configure a control with an
action using setAction, and then add that control directly
to the Container.a - the Action for the menu item to be addedActionpublic void addSeparator()
public void insert(String s, int pos)
s - the text for the menu item to addpos - an integer specifying the position at which to add the new
menu itemIllegalArgumentException - when the value of pos <
0public JMenuItem insert(JMenuItem mi, int pos)
JMenuitem at a given position.mi - the JMenuitem to addpos - an integer specifying the position at which to add the new
JMenuitemIllegalArgumentException - if the value of pos < 0public JMenuItem insert(Action a, int pos)
Action
object at a given position.a - the Action object for the menu item to addpos - an integer specifying the position at which to add the new
menu itemIllegalArgumentException - if the value of pos < 0public void insertSeparator(int index)
index - an integer specifying the position at which to insert the
menu separatorIllegalArgumentException - if the value of index <
0public JMenuItem getItem(int pos)
JMenuItem at the specified position. If the
component at pos is not a menu item, null is
returned. This method is included for AWT compatibility.pos - an integer specifying the positionnull if
the item as the specified position is not a menu itemIllegalArgumentException - if the value of pos < 0public int getItemCount()
getMenuComponentCount()public void remove(JMenuItem item)
item - the JMenuItem to be removed from the menupublic int getMenuComponentCount()
public Component getMenuComponent(int n)
n.n - the position of the component to be returnednull if there is no
popup menupublic Component[] getMenuComponents()
Components of the menu's subcomponents.
Note that this returns all Components in the popup menu,
including separators.Components or an empty array if there is
no popup menupublic boolean isMenuComponent(Component c)
c - the Component to be testedComponent exists, false otherwisepublic JPopupMenu getPopupMenu()
public JPopupMenu getPopupMenuOrNull()
public void addMenuListener(MenuListener l)
l - the listener to be addedpublic void removeMenuListener(MenuListener l)
l - the listener to be removedpublic MenuListener[] getMenuListeners()
MenuListeners added to this
JMenu with addMenuListener().MenuListeners added or an empty array if
no listeners have been addedprotected void fireMenuSelected()
Error - if there is a null listenerEventListenerListprotected void fireMenuDeselected()
Error - if there is a null listenerEventListenerListprotected void fireMenuCanceled()
Error - if there is a null listenerEventListenerListprotected JDropDownButton.WinListener createWinListener(JPopupMenu p)
p - the JPopupMenuJDropDownButton.WinListenerpublic void menuSelectionChanged(boolean isIncluded)
JMenuItem.menuSelectionChanged.isIncluded - true if this menu is active, false if it is notpublic MenuElement[] getSubElements()
MenuElements containing the submenu for
this menu component. If popup menu is null returns an empty
array. This method is required to conform to the MenuElement
interface. Note that since JSeparators do not conform to the
MenuElement interface, this array will only contain
JMenuItems.MenuElement objectspublic Component getComponent()
java.awt.Component used to paint this
MenuElement. The returned component is used to convert
events and detect if an event is inside a menu component.public void doClick(int pressTime)
AbstractButton.doClick in order to make the menu pop up.doClick in class AbstractButtonpressTime - indicates the number of milliseconds the button was
pressed forprotected JMenuItem createActionComponent(Action a)
JMenuItem for
Actions added to the JMenu. As of 1.3, this is
no longer the preferred method. Instead it is recommended to configure a
control with an action using setAction, and then adding that
control directly to the Container.a - the Action for the menu item to be addedActionprotected PropertyChangeListener createActionChangeListener(JMenuItem b)
PropertyChangeListener which
updates the control as changes to the Action occur. As of
1.3, this is no longer the preferred method for adding
Actions to a Container. Instead it is
recommended to configure a control with an action using
setAction, and then add that control directly to the
Container.Copyright © 2022 vpc open source initiative. All rights reserved.