Class LoadButton
- All Implemented Interfaces:
Animatable<LoadButton>
,CanDrop<LoadButton>
,Clickable<LoadButton>
,Draggable<LoadButton>
,HandleHotKey<LoadButton>
,HandleMouseEvents<LoadButton>
,Touchable<LoadButton>
The button component, that when it's pressed, the text on the button is replaced with a loading animation. When the loading has finished, the animation will stop automatically, and it will be replaced by the button text. During the animation, the user can't press the button again, as it becomes inactive during the loading process.
The animation can be started manually by using the start
method. It can be stopped by using the stop
method.
The component supports the use of animations that can be used for the button's appearance or disappearance.
To do this, use the setAnimation method, where the type can be specified.
For the applicable animations, see the Animation
enum
A counter can also be placed on the right side of the button. The counter can have any integer number in it. This can be used to count content, for example, the amount of unread messages
Supported events:
AnimationStart
AnimationEnd
,
Click
,
DoubleClick
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
TouchCancel
,
TouchEnd
,
TouchMove
,
TouchStart
,
HotKey
Drop
,
DragStart
,
DragEnd
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionLoadButton
(Icon icon, String text, LoadButtonAnimation animation, StyleElement... styles) Creates a new load button with the specified icon, text, animation and style(s)LoadButton
(String text, LoadButtonAnimation animation) Creates a new load button with the specified text and animation.LoadButton
(String text, LoadButtonAnimation animation, StyleElement... styles) Creates a new load button with the specified text, animation and style(s)LoadButton
(String id, Icon icon, String text, LoadButtonAnimation animation, StyleElement... styles) Creates a new load button with the specified icon, text, animation and style(s)LoadButton
(String id, String text, LoadButtonAnimation animation) Creates a new load button with the specified text and animation.LoadButton
(String id, String text, LoadButtonAnimation animation, StyleElement... styles) Creates a new load button with the specified text, animation and style(s) -
Method Summary
Modifier and TypeMethodDescriptionaddClickHandler
(ClickEventHandler handler) Adds a single click event handler to the component.Adds a double click event handler to the component.getIcon()
Gets the button icongetText()
Gets the button textvoid
init()
The component initialization method.void
onDefaultClickHandler
(MouseEvent event) void
final LoadButton
setAnimation
(LoadButtonAnimation animation) Sets the loading animation typeSets the button iconPlaces an image on the buttonsetSize
(ButtonSize size) Stets the button sizesetSpinnerColor
(Color color) Sets the loading spinner's color.Sets the button textsetType
(ButtonType type) Sets the button sizefinal void
start()
Starts the loading animation.
If the process starts on a click event, no need to start it manually, it will be automatic.final void
stop()
Stops the loading animation
If the process started by a click event, no need to stop it manually, it will be automatic.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.Touchable
addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler
-
Field Details
-
text
-
icon
-
image
-
-
Constructor Details
-
LoadButton
Creates a new load button with the specified text and animation.- Parameters:
text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
LoadButton
Creates a new load button with the specified text and animation.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
LoadButton
Creates a new load button with the specified text, animation and style(s)- Parameters:
text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.styles
- The style (type and/or size) of the button. For the applicable types, see theButtonType
enum. For the applicable sizes, see theButtonSize
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
LoadButton
Creates a new load button with the specified text, animation and style(s)- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.styles
- The style (type and/or size) of the button. For the applicable types, see theButtonType
enum. For the applicable sizes, see theButtonSize
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
LoadButton
Creates a new load button with the specified icon, text, animation and style(s)- Parameters:
icon
- The icon of the button. For the applicable icons, see theIcon
enum.text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.styles
- The style (type and/or size) of the button. For the applicable types, see theButtonType
enum. For the applicable sizes, see theButtonSize
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
LoadButton
public LoadButton(String id, Icon icon, String text, LoadButtonAnimation animation, StyleElement... styles) Creates a new load button with the specified icon, text, animation and style(s)- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)icon
- The icon of the button. For the applicable icons, see theIcon
enum.text
- The button textanimation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.styles
- The style (type and/or size) of the button. For the applicable types, see theButtonType
enum. For the applicable sizes, see theButtonSize
enum.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
-
Method Details
-
init
Description copied from class:Component
The component initialization method.Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.
- Overrides:
init
in classComponent<LoadButton>
- Throws:
JavaScriptLoadError
- If there was a JavaScript error during the initialization.
-
setText
Sets the button text- Parameters:
text
- The button text- Returns:
- The button component
-
getText
Gets the button text- Returns:
- The current button text. If it has no text, returns with
null
-
setIcon
Sets the button icon- Parameters:
icon
- The icon of the button. For the applicable icons, see theIcon
enum.- Returns:
- The button component
-
getIcon
Gets the button icon- Returns:
- The current button icon. If it has no icon, returns with
null
-
setImage
Places an image on the button- Parameters:
image
- The image that will be on the button. If specified asnull
, nothing will be placed.- Returns:
- The button component
-
setType
Sets the button size- Parameters:
type
- The size of the button. For the applicable types, see theButtonType
enum.- Returns:
- The button
-
setSize
Stets the button size- Parameters:
size
- The style size of the button. For the applicable types, see theButtonSize
enum.- Returns:
- The button
-
setAnimation
Sets the loading animation type- Parameters:
animation
- The loading animation. For the applicable animations, see theLoadButtonAnimation
enum.- Returns:
- The Load Button component
-
setSpinnerColor
Sets the loading spinner's color. Default is white- Parameters:
color
- The loading spinner's color. Available colors are listed in the enumColor
. You can use any standard HTML colors.- Returns:
- The Load Button component
-
start
public final void start()Starts the loading animation.
If the process starts on a click event, no need to start it manually, it will be automatic. -
stop
public final void stop()Stops the loading animation
If the process started by a click event, no need to stop it manually, it will be automatic. -
addClickHandler
Adds a single click event handler to the component. This handler runs when the user clicks once on the component.- Specified by:
addClickHandler
in interfaceClickable<LoadButton>
- Parameters:
handler
- TheClickEventHandler
implementation- Returns:
- The component
- See Also:
-
addDoubleClickHandler
Adds a double click event handler to the component. This handler runs when the user clicks twice on the component.- Specified by:
addDoubleClickHandler
in interfaceClickable<LoadButton>
- Parameters:
handler
- ADoubleClickEventHandler
implementation- Returns:
- The component
- See Also:
-
onDefaultClickHandler
- Parameters:
event
- The event object
-
onDefaultDoubleClickHandler
- Parameters:
event
- The event object
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
.- Specified by:
writeHTML
in classComponent<LoadButton>
- Returns:
- If the componentwas drawn,
true
, otherwisefalse
-