Class AbstractButton
- All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, SwingConstants
- Direct Known Subclasses:
JButton, JMenuItem, JToggleButton
AbstractButton.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, FILL_CHROME, FILL_DEFAULT, LEFT_ALIGNMENT, listenerList, 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
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractButton(com.vaadin.flow.component.Component peer) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactionPropertyChanged(Action a, String propertyName) voidvoidprotected voidvoidprotected intcheckHorizontalKey(int key, String exception) protected intcheckVerticalKey(int key, String exception) protected voidprotected ActionListenerprotected PropertyChangeListenerprotected ChangeListenerprotected ItemListenervoiddoClick()voiddoClick(int pressTime) protected voidfireActionPerformed(ActionEvent event) protected voidfireItemStateChanged(ItemEvent event) protected voidintbooleanintintgetIcon()intgetLabel()intgetModel()longObject[]getText()getUI()intintbooleanimageUpdate(Image arg0, int arg1, int arg2, int arg3, int arg4, int arg5) protected voidbooleanbooleanbooleanbooleanbooleanprotected voidpaintBorder(Graphics arg0) protected StringvoidvoidvoidvoidvoidvoidsetActionCommand(String command) voidsetBorderPainted(boolean borderPainted) voidsetContentAreaFilled(boolean contentAreaFilled) voidsetDisabledIcon(Icon disabledIcon) voidsetDisabledSelectedIcon(Icon disabledSelectedIcon) voidsetDisplayedMnemonicIndex(int index) voidsetFocusPainted(boolean focusPainted) voidsetHideActionText(boolean hideActionText) voidsetHorizontalAlignment(int alignment) voidsetHorizontalTextPosition(int textPosition) voidvoidsetIconTextGap(int iconTextGap) voidvoidsetLayout(LayoutManager mgr) voidvoidsetMnemonic(char mnemonic) voidsetMnemonic(int mnemonic) voidsetModel(ButtonModel arg0) Installs a user-suppliedButtonModel:getModel()reports it from here on, the JDK'ssuper.setEnabled(model .isEnabled())propagation runs, and"model"fires.voidsetMultiClickThreshhold(long threshhold) voidsetPressedIcon(Icon pressedIcon) voidsetRolloverEnabled(boolean rolloverEnabled) voidsetRolloverIcon(Icon rolloverIcon) voidsetRolloverSelectedIcon(Icon rolloverSelectedIcon) voidsetSelected(boolean arg0) Flips the selection flag and, on an actual change, firesItemEventthenChangeEvent— the fan-outDefaultButtonModel.setSelectedperforms.voidsetSelectedIcon(Icon selectedIcon) voidvoidvoidsetVerticalAlignment(int alignment) voidsetVerticalTextPosition(int textPosition) voidupdateUI()Methods inherited from class JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, 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, getUIClassID, 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, 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, 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, addSlotChild, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, fireHierarchyEvent, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, peerContentElement, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeSlotChild, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTreeMethods inherited from class Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, applyBackgroundToPeer, applyVisibleToPeer, awtListeners, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, defaultFillCssClass, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, fireComponentEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, isThemeDefault, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, 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, setMixingCutoutShape, setName, setSize, setSize, show, show, size, suppressMouseBridge, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, withPeer, withPeerOnLiveUI
-
Field Details
-
MODEL_CHANGED_PROPERTY
- See Also:
-
TEXT_CHANGED_PROPERTY
- See Also:
-
MNEMONIC_CHANGED_PROPERTY
- See Also:
-
MARGIN_CHANGED_PROPERTY
- See Also:
-
VERTICAL_ALIGNMENT_CHANGED_PROPERTY
- See Also:
-
HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY
- See Also:
-
VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
- See Also:
-
HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY
- See Also:
-
BORDER_PAINTED_CHANGED_PROPERTY
- See Also:
-
FOCUS_PAINTED_CHANGED_PROPERTY
- See Also:
-
ROLLOVER_ENABLED_CHANGED_PROPERTY
- See Also:
-
CONTENT_AREA_FILLED_CHANGED_PROPERTY
- See Also:
-
ICON_CHANGED_PROPERTY
- See Also:
-
PRESSED_ICON_CHANGED_PROPERTY
- See Also:
-
SELECTED_ICON_CHANGED_PROPERTY
- See Also:
-
ROLLOVER_ICON_CHANGED_PROPERTY
- See Also:
-
ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY
- See Also:
-
DISABLED_ICON_CHANGED_PROPERTY
- See Also:
-
DISABLED_SELECTED_ICON_CHANGED_PROPERTY
- See Also:
-
-
Constructor Details
-
AbstractButton
protected AbstractButton() -
AbstractButton
protected AbstractButton(com.vaadin.flow.component.Component peer)
-
-
Method Details
-
init
-
paramString
- Overrides:
paramStringin classJComponent
-
getLabel
-
getText
-
paintBorder
- Overrides:
paintBorderin classJComponent
-
setLayout
-
getAction
-
getMnemonic
public int getMnemonic() -
isSelected
public boolean isSelected() -
setSelected
public void setSelected(boolean arg0) Flips the selection flag and, on an actual change, firesItemEventthenChangeEvent— the fan-outDefaultButtonModel.setSelectedperforms.A plain
JButtonhas no visual selected state, but it very much has the selection state:new JButton("go").setSelected(true)thenisSelected()answerstrueon JDK 25, with anItemEventand aChangeEventdelivered on the way. Only the rendering is missing here, which is the half R_decline_effect_only permits dropping.JToggleButtonoverrides this to coordinate itsButtonGroupand its surrogate's model (D_jradiobutton). -
doClick
public void doClick() -
doClick
public void doClick(int pressTime) -
getModel
- Returns:
- the model
setModel(ButtonModel)installed, ornullwhen none was — the button's real state machine is the surrogate's, not reachable through this accessor (SD_sjbutton)
-
setRolloverEnabled
public void setRolloverEnabled(boolean rolloverEnabled) -
getIcon
-
getDisabledIcon
-
getSelectedIcon
-
getDisabledSelectedIcon
-
checkVerticalKey
-
checkHorizontalKey
-
removeNotify
public void removeNotify()- Overrides:
removeNotifyin classJComponent
-
isRolloverEnabled
public boolean isRolloverEnabled() -
setActionCommand
-
getActionCommand
-
removeActionListener
-
configurePropertiesFromAction
-
addActionListener
-
createActionPropertyChangeListener
-
getHideActionText
public boolean getHideActionText() -
setHideActionText
public void setHideActionText(boolean hideActionText) -
setDisplayedMnemonicIndex
- Throws:
IllegalArgumentException
-
setMnemonic
public void setMnemonic(char mnemonic) -
setMnemonic
public void setMnemonic(int mnemonic) -
setText
-
setIcon
-
isBorderPainted
public boolean isBorderPainted() -
removeChangeListener
-
removeItemListener
- Specified by:
removeItemListenerin interfaceItemSelectable
-
createChangeListener
-
createActionListener
-
createItemListener
-
addChangeListener
-
addItemListener
- Specified by:
addItemListenerin interfaceItemSelectable
-
setUI
-
setDisabledIcon
-
setDisabledSelectedIcon
-
addImpl
-
setAction
-
updateUI
public void updateUI()- Overrides:
updateUIin classJComponent
-
getPressedIcon
-
getRolloverSelectedIcon
-
getRolloverIcon
-
imageUpdate
- Specified by:
imageUpdatein interfaceImageObserver- Overrides:
imageUpdatein classComponent
-
setBorderPainted
public void setBorderPainted(boolean borderPainted) -
setIconTextGap
public void setIconTextGap(int iconTextGap) -
setContentAreaFilled
public void setContentAreaFilled(boolean contentAreaFilled) -
getUI
- Overrides:
getUIin classJComponent
-
setMargin
-
getMargin
-
setPressedIcon
-
setSelectedIcon
-
setRolloverIcon
-
setRolloverSelectedIcon
-
getVerticalAlignment
public int getVerticalAlignment() -
setVerticalAlignment
public void setVerticalAlignment(int alignment) -
getHorizontalAlignment
public int getHorizontalAlignment() -
setHorizontalAlignment
public void setHorizontalAlignment(int alignment) -
getVerticalTextPosition
public int getVerticalTextPosition() -
setVerticalTextPosition
public void setVerticalTextPosition(int textPosition) -
getHorizontalTextPosition
public int getHorizontalTextPosition() -
setHorizontalTextPosition
public void setHorizontalTextPosition(int textPosition) -
getIconTextGap
public int getIconTextGap() -
actionPropertyChanged
-
isFocusPainted
public boolean isFocusPainted() -
setFocusPainted
public void setFocusPainted(boolean focusPainted) -
isContentAreaFilled
public boolean isContentAreaFilled() -
getDisplayedMnemonicIndex
public int getDisplayedMnemonicIndex() -
setMultiClickThreshhold
public void setMultiClickThreshhold(long threshhold) -
getMultiClickThreshhold
public long getMultiClickThreshhold() -
setModel
Installs a user-suppliedButtonModel:getModel()reports it from here on, the JDK'ssuper.setEnabled(model .isEnabled())propagation runs, and"model"fires. The model itself is inert — the button's state machine lives in the surrogate's own ButtonModel (SD_sjbutton), so a foreign model receives no pressed/armed/selected pulses and drives nothing. That is the declined effect; the state and notification are owed (R_decline_effect_only, D_owed_events).The JDK's listener rewiring (
ChangeListener/ActionListener/ItemListeneronto the new model) is part of the same declined effect, and itsupdateMnemonicProperties/updateDisplayedMnemonicIndexcalls are R_layouts_close_enough rendering.getModel()keeps returningnullfor a button whose model was never set, which is what it did before — so this changes nothing for code that never installs one. -
getChangeListeners
-
fireStateChanged
protected void fireStateChanged() -
getActionListeners
-
fireActionPerformed
-
fireItemStateChanged
-
setLabel
-
getItemListeners
-
getSelectedObjects
- Specified by:
getSelectedObjectsin interfaceItemSelectable
-