Class Counter
Counter component
The component is a Span
component, on which a number is displayed. The component can be used on a menu item, or button, to count information that is relevant to the user.
A good example is the number of messages or notifications.
Supported events:
AnimationStart
AnimationEnd
,
Click
,
DoubleClick
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
Scrollable
TouchCancel
,
TouchEnd
,
TouchMove
,
TouchStart
,
Drop
,
DragStart
,
DragEnd
- Since:
- 4.0
- Author:
- JBStrap
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal Counter
add
(int value) Increments the counter value by the given valuefinal Counter
dec()
Decrements counter value by 1Gets the background color of the counter componentGets the counter component’s displayed value colorlong
getValue()
Gets the counter valuefinal Counter
inc()
Increments the counter value by 1final Counter
loss
(int value) Decrements the counter value by the given numberfinal Counter
setBackgoundColor
(Color color) Sets the background color of the counter Default background color is the theme WARNING colorfinal Counter
setBackgoundColor
(String color) Sets the background color of the counter Default background color is the theme WARNING color.final Counter
setTextColor
(Color color) Sets the text color of the counter Default text color is the theme text colorfinal Counter
setTextColor
(String color) Sets the color of the values on the counter.final Counter
setValue
(long value) Sets the value of the counter componentboolean
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, 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, 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
-
Constructor Details
-
Counter
public Counter()Creates the counter component -
Counter
Creates the counter component with specieid id- 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.)
-
-
Method Details
-
setValue
Sets the value of the counter component- Parameters:
value
- The value we want to display in the counter- Returns:
- The counter component
-
inc
Increments the counter value by 1- Returns:
- The counter component
-
dec
Decrements counter value by 1- Returns:
- The counter component
-
add
Increments the counter value by the given value- Parameters:
value
- The value we want to increment the counter by- Returns:
- The counter component
-
loss
Decrements the counter value by the given number- Parameters:
value
- The value we want to decrement the counter by- Returns:
- The counter component
-
getValue
public long getValue()Gets the counter value- Returns:
- The current value of the counter
-
setBackgoundColor
Sets the background color of the counter Default background color is the theme WARNING color- Parameters:
color
- Counter background color Available colors are listed in the enumColor
If the entered value isnull
, the counter will appear with the default WARNING color.- Returns:
- The counter component
-
setBackgoundColor
Sets the background color of the counter Default background color is the theme WARNING color.- Parameters:
color
- Counter Counter background color as defined in CSS3. If anull
value is set, the counter will appear with the default WARNING color.- Returns:
- The counter component
-
setTextColor
Sets the text color of the counter Default text color is the theme text color- Overrides:
setTextColor
in classComponent<Counter>
- Parameters:
color
- Counter text color Available colors are listed in the enumColor
If the entered value isnull
, the counter will appear with the default text color.- Returns:
- The counter component
-
setTextColor
Sets the color of the values on the counter. The default color is white.- Parameters:
color
- The color, specified using CSS3 standard units. Ifnull
, the default white color will be used.- Returns:
- The counter component
-
getBackgoundColor
Gets the background color of the counter component- Returns:
- The background color of the counter component
-
getTextColor
Gets the counter component’s displayed value color- Overrides:
getTextColor
in classComponent<Counter>
- Returns:
- The counter component’s displayed value color
-
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
.
-