Package com.vaadin.featurepack.ui
Class FButton
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.button.Button
com.vaadin.featurepack.ui.FButton
- All Implemented Interfaces:
ClientConnector,FAbstractClientConnector,FSizeable,HasSizeable,FAbstractComponent,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<com.vaadin.flow.component.button.Button>,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.button.Button>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<com.vaadin.flow.component.button.Button>,com.vaadin.flow.component.FocusNotifier<com.vaadin.flow.component.button.Button>,com.vaadin.flow.component.HasAriaLabel,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasPrefix,com.vaadin.flow.component.shared.HasSuffix,com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.button.ButtonVariant>,com.vaadin.flow.component.shared.HasTooltip,Serializable
public class FButton
extends com.vaadin.flow.component.button.Button
implements FAbstractComponent, HasSizeable
A generic button component with Vaadin Framework 7 and 8 compatible API.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClick event.static interfaceInterface for listening for aFButton.ClickEventfired by aComponent.static classAShortcutListenerspecifically made to define a keyboard shortcut that invokes a click on the given button.Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.ClickNotifier
com.vaadin.flow.component.ClickNotifier.ClickFiltersJsNested classes/interfaces inherited from interface com.vaadin.featurepack.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListenerNested classes/interfaces inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
FAbstractClientConnector.LegacyMethodEventNested classes/interfaces inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
FAbstractComponent.DataKeyNested classes/interfaces inherited from interface com.vaadin.flow.component.Focusable
com.vaadin.flow.component.Focusable.FocusJsNested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFButton()Creates a new push button.Creates a new push button with the given icon.FButton(Resource icon, FButton.ClickListener listener) Creates a new push button with a click listener.FButton(com.vaadin.flow.component.icon.IconFactory iconFactory) Creates a new push button with the given icon.Creates a new push button with the given caption.Creates a new push button with the given caption and icon.FButton(String caption, FButton.ClickListener listener) Creates a new push button with a click listener.Creates a new push button with the given caption and icon factory. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddClickListener(FButton.ClickListener listener) Adds the button click listener.voidclick()Simulates a button click, notifying all server-side listeners.protected voidFires a click event to all listeners without any event details.protected voidfireClick(MouseEventDetails details) Fires a click event to all listeners.protected voidfireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) com.vaadin.flow.component.ComponentgetIcon()Gets the icon component of the component.Returns the icon's alt text.booleanReturn HTML rendering settingprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidremoveClickListener(FButton.ClickListener listener) Removes the button click listener.voidRemoves the keyboard shortcut previously set withsetClickShortcut(int, int...).voidsetCaption(String caption) Sets the caption of the component.voidsetClickShortcut(int keyCode, int... modifiers) Makes it possible to invoke a click on this button by pressing the givenShortcutAction.KeyCodeand (optional)ShortcutAction.ModifierKeys.
The shortcut is global (bound to the containing Window).voidsetHtmlContentAllowed(boolean htmlContentAllowed) Set whether the caption text is rendered as HTML or not.voidSets the component's icon and alt text.voidSets the component's icon and alt text.voidsetIconAlternateText(String iconAltText) voidsetLabelComponent(com.vaadin.flow.component.Component labelComponent) Sets the component's label component.Methods inherited from class com.vaadin.flow.component.button.Button
addBlurListener, addFocusListener, addFocusShortcut, bindEnabled, bindText, clickInClient, getDisableOnClickMode, getDownloadHandler, getText, isAutofocus, isDisableOnClick, isIconAfterText, remove, setAutofocus, setDisableOnClick, setDisableOnClick, setDownloadHandler, setEnabled, setIcon, setIconAfterText, setTextMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, findAncestor, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, getUIOrThrow, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.featurepack.server.FAbstractClientConnector
addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, attach, detach, doConnectorOnAttach, doConnectorOnDetach, fireEvent, fireEvent, getAllChildrenIterable, getFListeners, getFlowComponent, getResource, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeListener, removeListener, setResourceMethods inherited from interface com.vaadin.featurepack.ui.FAbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, addStyleNames, beforeClientResponse, getCaption, getComponentError, getData, getDescription, getFErrorIndicator, getFErrorMessage, getFId, getFParent, getIconResource, getPrimaryStyleName, getStyleName, isCaptionAsHtml, isImmediate, isResponsive, notifyParentAboutStyleChanges, removeContextClickListener, removeShortcutListener, removeStyleName, removeStyleNames, setCaptionAsHtml, setComponentError, setData, setDescription, setDescription, setIcon, setIcon, setIconResource, setImmediate, setLocale, setPrimaryStyleName, setResponsive, setStyleName, setStyleNameMethods inherited from interface com.vaadin.flow.component.Focusable
blur, focus, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.HasAriaLabel
getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy, setAriaLabelledByMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.featurepack.server.HasSizeable
getFHeight, getFWidth, getHeightUnits, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefinedMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasText
getWhiteSpace, setWhiteSpaceMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipMarkdown, setTooltipText
-
Field Details
-
clickShortcut
-
-
Constructor Details
-
FButton
public FButton()Creates a new push button. -
FButton
Creates a new push button with the given caption.- Parameters:
caption- the Button caption.
-
FButton
Creates a new push button with the given icon.- Parameters:
icon- the icon
-
FButton
public FButton(com.vaadin.flow.component.icon.IconFactory iconFactory) Creates a new push button with the given icon.- Parameters:
iconFactory- the icon factory to use
-
FButton
Creates a new push button with the given caption and icon.- Parameters:
caption- the captionicon- the icon
-
FButton
Creates a new push button with the given caption and icon factory.- Parameters:
caption- the captioniconFactory- the icon factory to use
-
FButton
Creates a new push button with a click listener.- Parameters:
caption- the Button caption.listener- the Button click listener.
-
FButton
Creates a new push button with a click listener.- Parameters:
icon- the Button icon.listener- the Button click listener.- Since:
- 8.2
-
-
Method Details
-
addClickListener
Adds the button click listener.- Parameters:
listener- the Listener to be added.
-
removeClickListener
Removes the button click listener.- Parameters:
listener- the Listener to be removed.
-
click
public void click()Simulates a button click, notifying all server-side listeners. No action is taken is the button is disabled.- Overrides:
clickin classcom.vaadin.flow.component.button.Button
-
fireClick
protected void fireClick()Fires a click event to all listeners without any event details. In subclasses, overridefireClick(MouseEventDetails)instead of this method. -
setClickShortcut
public void setClickShortcut(int keyCode, int... modifiers) Makes it possible to invoke a click on this button by pressing the givenShortcutAction.KeyCodeand (optional)ShortcutAction.ModifierKeys.
The shortcut is global (bound to the containing Window).- Parameters:
keyCode- the keycode for invoking the shortcutmodifiers- the (optional) modifiers for invoking the shortcut, null for none
-
removeClickShortcut
public void removeClickShortcut()Removes the keyboard shortcut previously set withsetClickShortcut(int, int...). -
setCaption
Description copied from interface:FAbstractComponentSets the caption of the component.A caption is an explanatory textual label accompanying a user interface component, usually shown above, left of, or inside the component. Icon (see
setIcon()is closely related to caption and is usually displayed horizontally before or after it, depending on the component and the containing layout.- Specified by:
setCaptionin interfaceFAbstractComponent- Parameters:
caption- the new caption for the component.
-
setIcon
Sets the component's icon and alt text. An alt text is shown when an image could not be loaded, and read by assistive devices.- Parameters:
iconFactory- the icon factory to useiconAltText- String to use as alt text
-
setIcon
Sets the component's icon and alt text. An alt text is shown when an image could not be loaded, and read by assistive devices.- Parameters:
icon- the icon to be shown with the component's caption.iconAltText- String to use as alt text
-
getIconAlternateText
Returns the icon's alt text.- Returns:
- String with the alt text
-
setIconAlternateText
-
setHtmlContentAllowed
public void setHtmlContentAllowed(boolean htmlContentAllowed) Set whether the caption text is rendered as HTML or not. You might need to re-theme button to allow higher content than the original text style. If set to true, the captions are passed to the browser as html and the developer is responsible for ensuring no harmful html is used. If set to false, the content is passed to the browser as plain text.- Parameters:
htmlContentAllowed-trueif caption is rendered as HTML,falseotherwise
-
isHtmlContentAllowed
public boolean isHtmlContentAllowed()Return HTML rendering setting- Returns:
trueif the caption text is to be rendered as HTML,falseotherwise
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-
setLabelComponent
public void setLabelComponent(com.vaadin.flow.component.Component labelComponent) Description copied from interface:FAbstractComponentSets the component's label component. Flow components that support caption component usually overrides this.- Specified by:
setLabelComponentin interfaceFAbstractComponent- Parameters:
labelComponent- the new label component for the component.
-
getIcon
public com.vaadin.flow.component.Component getIcon()Description copied from interface:FAbstractComponentGets the icon component of the component. Returns Component type to be compatible with Flow Button component.See
FAbstractComponent.setIcon(Icon)for a detailed description of the icon.- Specified by:
getIconin interfaceFAbstractComponent- Overrides:
getIconin classcom.vaadin.flow.component.button.Button- Returns:
- the icon component of the component or
nullif the component has no icon - See Also:
-
fireEvent
protected void fireEvent(com.vaadin.flow.component.ComponentEvent<?> componentEvent) - Overrides:
fireEventin classcom.vaadin.flow.component.Component
-