Class ListBox
- All Implemented Interfaces:
Animatable<ListBox>
,CanDrop<ListBox>
,Draggable<ListBox>
,HandleMouseEvents<ListBox>
,Scrollable<ListBox>
List component
This component displays an ordered or unordered list on the interface. Each item of the ordered list comes with a number before, and the item content is indented. Items of an unordered list are preceded by a dot and the item text is indented.
Not only texts, but also any arbitrary components may be placed in a list component and will be displayed in the above described manner on the interface.
Supported events:
AnimationStart
AnimationEnd
,
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
Scrollable
Drop
,
DragStart
,
DragEnd
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component<?> component) Adds the specified component as a subcomponent, and redraws the component immediatelyaddItemList
(List<?> items) Adds multiple items to the list Items provided can be textual or components or of both typesaddTextListItem
(String text) Adds a text component to the list as a list itemfinal ListBox
clear()
Deletes all items of the listgetItems()
Gets all items of the listboolean
isSorted()
Defines whether the list is orderedremoveComponent
(Component<?> component) Removes the specified subcomponent.setSorted
(boolean sorted) Sets if the list is orderedint
size()
Gets the number of items in the listboolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, 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, 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.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.Scrollable
addScrollHandler
-
Constructor Details
-
ListBox
public ListBox()Creates an empty unordered list -
ListBox
Creates an empty unordered list with the specified 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.)
-
ListBox
public ListBox(boolean sorted) Creates an empty list and sets if the list is ordered or unordered- Parameters:
sorted
- If atrue
value is set, the list will be displayed as ordered, otherwise as an unordered list.
-
ListBox
Creates an empty list and sets if the list is ordered or unordered- 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.)sorted
- If atrue
value is set, the list will be displayed as ordered, otherwise as an unordered list.
-
-
Method Details
-
isSorted
public boolean isSorted()Defines whether the list is ordered- Returns:
true
if the list is ordered otherwisefalse
-
setSorted
Sets if the list is ordered- Parameters:
sorted
- Iftrue
is set, the list is displayed as an ordered list, otherwise as an unordered list- Returns:
- The list component
-
addTextListItem
Adds a text component to the list as a list item- Parameters:
text
- Text content to be displayed as a list item- Returns:
- The list component
-
addItemList
Adds multiple items to the list Items provided can be textual or components or of both types- Parameters:
items
- An enumeration of items we want to add to the list If the list item is a component, the given component will be added to the list. If the list item is not a component, a textual representation will be added to the list instead.- Returns:
- The list component
-
getItems
Gets all items of the list- Returns:
- An enumeration of items of the List type, with all items being a list item If the list is empty, an empty list is the return value
-
size
public int size()Gets the number of items in the list- Returns:
- The number of items in the list If the list is empty, the return value is 0
-
addComponent
Description copied from class:Component
Adds the specified component as a subcomponent, and redraws the component immediately- Overrides:
addComponent
in classComponent<ListBox>
- Parameters:
component
- The component to be added- Returns:
- The component
-
clear
Deletes all items of the list- Returns:
- The list component
-
removeComponent
Description copied from class:Component
Removes the specified subcomponent.- Overrides:
removeComponent
in classComponent<ListBox>
- Parameters:
component
- The component instance- Returns:
- The component
-
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
.
-