Class Button
- All Implemented Interfaces:
Animatable<Button>
,CanDrop<Button>
,Clickable<Button>
,Draggable<Button>
,HandleHotKey<Button>
,HandleMouseEvents<Button>
,Touchable<Button>
Button component
With this component, a button can be placed on the interface. The button can be customized, and it can have an icon and/or text on it. The click event handler can be implemented on the server side.
The button component supports the use of animations, that can be used when the button appears or disappears.
The animation can be set by using the setAnimation method.
For the types of animation, 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:
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
ConstructorDescriptioncreates a button with the specified iconCreates a button with the specified icon and textButton
(Icon icon, String text, StyleElement... styles) Creates a button with the specified icon, text and style(s).Creates a button with the specified textButton
(String text, StyleElement... styles) Creates a button with the specified text and style(s).Creates a button with the specified iconCreates a button with the specified icon and textButton
(String id, Icon icon, String text, StyleElement... styles) Creates a button with the specified icon, text and style(s).Creates a button with the specified text -
Method Summary
Modifier and TypeMethodDescriptionfinal long
Gets the counter valuegetIcon()
Gets the button icongetText()
Gets the button textboolean
Checks if the button is rounded.final Button
setCounter
(long value) Adds a counter to the right side of the button.Sets the button iconPlaces an image on the buttonsetRounded
(boolean rounded) Toggles on/off the roundedness of a button.setSize
(ButtonSize size) Stets the button sizeSets the button textsetType
(ButtonType type) Sets the button sizeboolean
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, init, 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.Clickable
addClickHandler, addDoubleClickHandler
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
-
Button
creates a button with the specified icon- Parameters:
icon
- the icon of the button. for the applicable icons, see theIcon
enum.- Throws:
IllegalStateException
- if the component is set to be both private and public, through an annotation.
-
Button
Creates a button with the specified icon- 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.- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Button
Creates a button with the specified text- Parameters:
text
- The button text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Button
Creates a button with the specified text- 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 text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Button
Creates a button with the specified icon and text- Parameters:
icon
- The icon of the button. For the applicable icons, see theIcon
enum.text
- The button text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Button
Creates a button with the specified icon and text- 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 text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Button
Creates a button with the specified text and style(s).- Parameters:
text
- The button textstyles
- 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.
-
Button
Creates a button with the specified icon, text and style(s).- Parameters:
icon
- The icon of the button. For the applicable icons, see theIcon
enum.text
- The button textstyles
- 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.
-
Button
Creates a button with the specified icon, text 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 textstyles
- 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
-
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
-
setCounter
Adds a counter to the right side of the button.- Parameters:
value
- The counter value- Returns:
- The button component
-
getCounter
public final long getCounter()Gets the counter value- Returns:
- The current value on the button counter. If the button has no counter, returns with -1.
-
setRounded
Toggles on/off the roundedness of a button.- Parameters:
rounded
- Iftrue
is specified, the button is displayed as a rounded button, Otherwise it is rectangular- Returns:
- The button
-
isRounded
public boolean isRounded()Checks if the button is rounded.- Returns:
- If
true
is specified, the button is displayed as a rounded button, otherwise rectangular
-
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
.
-