Class Badge
- All Implemented Interfaces:
Animatable<Badge>
,CanDrop<Badge>
,Clickable<Badge>
,Draggable<Badge>
,HandleHotKey<Badge>
,HandleMouseEvents<Badge>
,Scrollable<Badge>
,Touchable<Badge>
Badge component
This component displays a badge which can contain an icon. The color can also be specified. The badges have rounded edges. See the JBStrap showcase for an example
Supported events:
AnimationStart
AnimationEnd
,
Click
,
DoubleClick
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
Scrollable
TouchCancel
,
TouchEnd
,
TouchMove
,
TouchStart
,
Drop
,
DragStart
,
DragEnd
HotKey
- 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
ConstructorDescriptionBadge()
Creates an empty badge component.Creates a badge with the specified icon and textBadge
(Icon icon, String text, StyleElement... styles) Creates a badge with the specified icon, text and styleCreates a badge with the specified textCreates a badge with the specified icon and textBadge
(String id, Icon icon, String text, StyleElement... styles) Creates a badge with the specified icon, text and styleCreates a badge with the specified text -
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 icon of the componentgetText()
Gets the text content of the componentboolean
Determine whether the sides of the badge are roundedsetBadgeType
(BadgeType badgeType) Sets the badge typeSets the icon of the componentsetRounded
(boolean rounded) Set whether the sides of the badge are rounded.Sets the text content of the componentsetTextType
(TextType textType) Sets the type of the badge textboolean
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.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.Scrollable
addScrollHandler
Methods inherited from interface com.jbstrap.ui.Touchable
addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler
-
Constructor Details
-
Badge
public Badge()Creates an empty badge component.- Throws:
IllegalStateException
- If the component is set to be both Private and Public through an annotation.
-
Badge
Creates a badge with the specified text- Parameters:
text
- The text that will be on the badge. If it's specified asnull
, there won't be any text on the badge- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Badge
Creates a badge 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 text that will be on the badge. If it's specified asnull
, there won't be any text on the badge- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Badge
Creates a badge with the specified icon and text- Parameters:
icon
- The icon that will be on the badge. For the applicable icons, see theIcon
enum. If specified asnull
, no icon will be on the badge.text
- The text that will be on the badge. If it's specified asnull
, there won't be any text on the badge- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Badge
Creates a badge 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 that will be on the badge. For the applicable icons, see theIcon
enum. If specified asnull
, no icon will be on the badge.text
- The text that will be on the badge. If it's specified asnull
, there won't be any text on the badge- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Badge
Creates a badge with the specified icon, text and style- Parameters:
icon
- The icon that will be on the badge. For the applicable icons, see theIcon
enum. If specified asnull
, no icon will be on the badge.text
- The text that will be on the badge. If it's specified asnull
, there won't be any text on the badgestyles
- One or more style, that will be applied to the badge. For the applicable badge styles, see theBadgeType
enum, and/or theTextType
enum, that can be applied to the badge text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
Badge
Creates a badge with the specified icon, text and style- 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 that will be on the badge. For the applicable icons, see theIcon
enum. If specified asnull
, no icon will be on the badge.text
- The text that will be on the badge. If it's specified asnull
, there won't be any text on the badgestyles
- One or more style, that will be applied to the badge. For the applicable badge styles, see theBadgeType
enum, and/or theTextType
enum, that can be applied to the badge text- Throws:
IllegalStateException
- If the component is set to be both Private and Public, through an annotation.
-
-
Method Details
-
setText
Sets the text content of the component- Parameters:
text
- The text that will appear in the component. If specified asnull
, nothing will appear in it.- Returns:
- The span component
-
getText
Gets the text content of the component- Returns:
- The text content or
null
if no text was specified
-
setIcon
Sets the icon of the component- Parameters:
icon
- The icon that will appear in the beginning of the component.For the applicable icons, see theIcon
enum. If specified asnull
, no icon will be used.- Returns:
- The span component
-
getIcon
Gets the icon of the component- Returns:
- The icon of the component or
null
if no icon was specified
-
setBadgeType
Sets the badge type- Parameters:
badgeType
- The badge type. For the applicable badge styles, see theBadgeType
enum- Returns:
- The badge component
-
setTextType
Sets the type of the badge text- Parameters:
textType
- The type of the badge text. For the applicable text styles, see theTextType
enum- Returns:
- The badge component
-
addClickHandler
Description copied from interface:Clickable
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<Badge>
- Parameters:
handler
- TheClickEventHandler
implementation- Returns:
- The component
- See Also:
-
addDoubleClickHandler
Description copied from interface:Clickable
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<Badge>
- Parameters:
handler
- ADoubleClickEventHandler
implementation- Returns:
- The component
- See Also:
-
setRounded
Set whether the sides of the badge are rounded. By default, the pages of the badge are torn off.- Parameters:
rounded
- If set totrue
, badge pages will be retrieved, otherwise not.- Returns:
- The badge component
-
isRounded
public boolean isRounded()Determine whether the sides of the badge are rounded- Returns:
- If
true
, the pages of the badge are rounded, otherwise they are not
-
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
.
-