Class AbstractButton
java.lang.Object
vaadinx.awt.Component
vaadinx.awt.Container
vaadinx.swing.JComponent
vaadinx.swing.AbstractButton
- All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, SwingConstants
- Direct Known Subclasses:
JButton, JMenuItem, JToggleButton
Emulator for
AbstractButton.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ActionListenerThe model'sActionListener,createActionListener()'s result.static final Stringprotected ChangeEventOnly oneChangeEventis needed per button, as its sole state is the source.protected ChangeListenerThe model'sChangeListener,createChangeListener()'s result.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected ItemListenerThe model'sItemListener,createItemListener()'s result.static final Stringstatic final Stringprotected ButtonModelThe button's state machine — armed, pressed, selected, enabled, rollover — and its action command, as in the JDK.static 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) Peers onpeer, built by the caller.protected <P extends com.vaadin.flow.component.Component>AbstractButton(Class<P> peerType, Supplier<? extends P> peerFactory) The lazy form: seeComponent(Class, java.util.function.Supplier). -
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) Pulses the model as a press and release would, so a disabled button does nothing and a toggle button flips.protected voidfireActionPerformed(ActionEvent event) Deliverseventwith this button as its source, as the JDK does; a model's event carries no command when the model has none, and the button'sgetActionCommand()stands in.protected voidfireItemStateChanged(ItemEvent event) Deliverseventwith this button as both source and item, as the JDK does.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) voidsetEnabled(boolean b) Enables the component and its model, which is what gatesdoClick()and a click.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 newModel) Moves the button's listeners from the old model tonewModel, takes its enabled state, hands it to the surrogate to render, and fires"model".voidsetMultiClickThreshhold(long threshhold) voidsetPressedIcon(Icon pressedIcon) voidsetRolloverEnabled(boolean rolloverEnabled) voidsetRolloverIcon(Icon rolloverIcon) voidsetRolloverSelectedIcon(Icon rolloverSelectedIcon) voidsetSelected(boolean b) Hands the flag to the model, which fires on an actual change:ItemEventthenChangeEventfrom aDefaultButtonModel, the reverse from aJToggleButton.ToggleButtonModel, which also consults itsButtonGroup.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, 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, peerIs, 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:
-
model
The button's state machine — armed, pressed, selected, enabled, rollover — and its action command, as in the JDK. The emulator builds it and listens to it; the surrogate is handed the same instance, so a browser click pulses this model and the surrogate renders its selection. -
changeListener
The model'sChangeListener,createChangeListener()'s result. -
actionListener
The model'sActionListener,createActionListener()'s result. -
itemListener
The model'sItemListener,createItemListener()'s result. -
changeEvent
Only oneChangeEventis needed per button, as its sole state is the source.
-
-
Constructor Details
-
AbstractButton
protected AbstractButton() -
AbstractButton
protected AbstractButton(com.vaadin.flow.component.Component peer) Peers onpeer, built by the caller. Installs no model: as in the JDK, the concrete subclass's constructor does (setModel(ButtonModel)). -
AbstractButton
protected <P extends com.vaadin.flow.component.Component> AbstractButton(Class<P> peerType, Supplier<? extends P> peerFactory) The lazy form: seeComponent(Class, java.util.function.Supplier).
-
-
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 b) Hands the flag to the model, which fires on an actual change:ItemEventthenChangeEventfrom aDefaultButtonModel, the reverse from aJToggleButton.ToggleButtonModel, which also consults itsButtonGroup.A plain
JButtonhas the selection state but no rendering of it: only the effect is missing, the half R_decline_effect_only permits dropping. -
doClick
public void doClick() -
doClick
public void doClick(int pressTime) Pulses the model as a press and release would, so a disabled button does nothing and a toggle button flips. The JDK paints the pressed state and sleepspressTimebetween press and release; nothing paints here, so neither happens. -
getModel
-
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
- Returns:
- the model's command, or the button's text when the model has none
-
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
- Returns:
- the listener
setModel(ButtonModel)installs on the model; shared with the other two
-
createActionListener
- Returns:
- the listener
setModel(ButtonModel)installs on the model; shared with the other two
-
createItemListener
- Returns:
- the listener
setModel(ButtonModel)installs on the model; shared with the other two
-
addChangeListener
-
addItemListener
- Specified by:
addItemListenerin interfaceItemSelectable
-
setEnabled
public void setEnabled(boolean b) Enables the component and its model, which is what gatesdoClick()and a click.- Overrides:
setEnabledin classJComponent
-
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
Moves the button's listeners from the old model tonewModel, takes its enabled state, hands it to the surrogate to render, and fires"model". Anullmodel is legal, as in the JDK, and leaves a button whose state accessors throw.The JDK's mnemonic resync from the new model is not reproduced: the mnemonic is the button's own field here, not the model's.
-
getChangeListeners
-
fireStateChanged
protected void fireStateChanged() -
getActionListeners
-
fireActionPerformed
Deliverseventwith this button as its source, as the JDK does; a model's event carries no command when the model has none, and the button'sgetActionCommand()stands in. -
fireItemStateChanged
Deliverseventwith this button as both source and item, as the JDK does. -
setLabel
-
getItemListeners
-
getSelectedObjects
- Specified by:
getSelectedObjectsin interfaceItemSelectable- Returns:
- the button's text while it is selected,
nullotherwise
-