AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
com.anylogic.engine.internal.Child, Locatable2D, AggregatableAnimationElement, HasLevel, LevelElement, SVGElement, java.io.Serializable, java.lang.Cloneable

public class ShapeListBox
extends ShapeInputControl
List box control. Embeds a JList component in a JScrollPane.
This object is only available in the AnyLogic Professional
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class com.anylogic.engine.presentation.ShapeControl

ShapeControl.ValueType

Field Summary

Fields 
java.lang.String value
The currently selected item of the list box (or first item of multiselection) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected item from other places
java.lang.String[] values
The currently selected items of the list box (in the multiple-selection mode) that can be accessed in the overridden action() method.
Use getValues() to obtain the currently selected items from other places
Modifier and Type Field Description

Fields inherited from class com.anylogic.engine.presentation.ShapeControl

TYPE_DOUBLE, TYPE_INT, TYPE_STRING

Fields inherited from class com.anylogic.engine.presentation.Shape

UNKNOWN_NAME

Constructor Summary

Constructors 
ShapeListBox​(Presentable p, boolean ispublic, double x, double y, double width, double height, java.awt.Color backgroundColor, java.awt.Color textColor, boolean enabled, java.awt.Font font, java.lang.String[] items, boolean multipleSelectionMode)
Creates a persistent list box control.
ShapeListBox​(Presentable p, boolean ispublic, double x, double y, double width, double height, java.awt.Color backgroundColor, java.awt.Color textColor, java.awt.Font font, java.lang.String[] items, boolean multipleSelectionMode)
Deprecated.
may be removed in future releases
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods 
void executeUserAction​(java.lang.String value)
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
java.lang.String[] getItems()
Returns array of String items currently in this list box.
java.lang.String getValue()
Returns the currently selected text item if in single-selection mode or the first selected text item if in multiple-selection mode Returns null if there is no selection.
int getValueIndex()
Returns the index of the currently selected text item or -1 when there is no selection.
java.lang.String[] getValues()
Returns an array of selected text items (for use in multiple-selection mode)
Returns empty array if there is no selection
int[] getValuesIndices()
Returns an array of selected items' indices (for use in multiple-selection mode).
void setItems​(java.lang.String[] items)
Sets new items for this list box
This method preserves current list box values if current values are contained in new items.
This method doesn't execute user action code (even if current selection changes).
Note that provided array is used internally and shouldn't be changed by user after this method is called.
void setItems​(java.lang.String[] items, boolean callAction)
Sets new items for this list box.
void setValue​(java.lang.String text)
Sets the selected text item of the list box.
Clears list box selection if text is null
Doesn't execute user action code
void setValue​(java.lang.String text, boolean callAction)
Sets the selected text item of the list box.
void setValueIndex​(int valueIndex)
Selects the item with the given index.
Clears list box selection if valueIndex is negative.
Doesn't execute user action code
void setValueIndex​(int valueIndex, boolean callAction)
Selects the item with the given index.
void setValues​(java.lang.String[] texts)
Sets the selected text items of the list box (in the multiple-selection mode)
Clears list box selection if texts is null or empty
Doesn't execute user action code
void setValues​(java.lang.String[] selectedTexts, boolean callAction)
Sets the selected text items of the list box (in multiple-selection mode) Clears list box selection if texts is null or empty Executes user action code (if any exists) if callAction parameter is true
void setValuesIndices​(int[] valuesIndices)
Selects items with the given indices (in the multiple-selection mode)
Clears list box selection if valuesIndices is null or empty.
Doesn't execute user action code
void setValuesIndices​(int[] valuesIndices, boolean callAction)
Selects items with the given indices (in multiple-selection mode) Clears list box selection if valuesIndices is null or empty.
Modifier and Type Method Description

Methods inherited from class com.anylogic.engine.presentation.ShapeInputControl

postSVGShapeSpecificAttributes

Methods inherited from class com.anylogic.engine.presentation.ShapeControl

action, clone, contains, executeAction, getHeight, getPresentable, getWidth, isEnabled, randomPointInside, restoreOwner, setEnabled, setHeight, setValueToDefault, setWidth

Methods inherited from class com.anylogic.engine.presentation.Shape

canHandleClick, findSVGElement, getDrawMode, getGroup, getLevel, getName, getRotation, getScaleX, getScaleY, getSVGId, getX, getY, isJava2DSwingPresentation, isPublic_xjal, isSVGPresentation, isVisible, onAggregatorVisibilityChanged, onClick, randomPointInside, removeSVGFromOwner, removeSVGImage, resetSVGState, setLevel, setPos, setPos, setPublic_xjal, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY, updateDynamicProperties, updateDynamicPropertiesStructural, updateSVGProperties

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, postInitialize

Field Detail

value

@AnyLogicInternalAPI
public java.lang.String value
The currently selected item of the list box (or first item of multiselection) that can be accessed in the overridden action() method.
Use getValue() to obtain the currently selected item from other places

values

@AnyLogicInternalAPI
public java.lang.String[] values
The currently selected items of the list box (in the multiple-selection mode) that can be accessed in the overridden action() method.
Use getValues() to obtain the currently selected items from other places

Constructor Detail

ShapeListBox

public ShapeListBox​(Presentable p,
                    boolean ispublic,
                    double x,
                    double y,
                    double width,
                    double height,
                    java.awt.Color backgroundColor,
                    java.awt.Color textColor,
                    java.awt.Font font,
                    java.lang.String[] items,
                    boolean multipleSelectionMode)
Deprecated.
may be removed in future releases

ShapeListBox

public ShapeListBox​(Presentable p,
                    boolean ispublic,
                    double x,
                    double y,
                    double width,
                    double height,
                    java.awt.Color backgroundColor,
                    java.awt.Color textColor,
                    boolean enabled,
                    java.awt.Font font,
                    java.lang.String[] items,
                    boolean multipleSelectionMode)
Creates a persistent list box control. You should override the action() method, in which you can access the current selection of list box as "values".
Parameters:
p - the presentable object owning this control
ispublic - if true, the control is visible on container's presentation
x - the x coordinate
y - the y coordinate
width - the width
height - the height
backgroundColor - the background color color
textColor - the text color
enabled - the initial enabled state
font - the text font
items - the array of text items of the list box
multipleSelectionMode - if true this list box will support multiple intervals selection, otherwise - only single item selection

Method Detail

setValue

public void setValue​(java.lang.String text)
Sets the selected text item of the list box.
Clears list box selection if text is null
Doesn't execute user action code
Parameters:
text - the new selected text item or null

setValue

public void setValue​(java.lang.String text,
                     boolean callAction)
Sets the selected text item of the list box. Clears list box selection if text is null Executes user action code (if any exists) if callAction parameter is true
Parameters:
text - the new selected text item or null
callAction - if true user action code (if any exists) will be executed

setValueIndex

public void setValueIndex​(int valueIndex)
Selects the item with the given index.
Clears list box selection if valueIndex is negative.
Doesn't execute user action code
Parameters:
valueIndex - the item index

setValueIndex

public void setValueIndex​(int valueIndex,
                          boolean callAction)
Selects the item with the given index. Clears list box selection if valueIndex is negative. Executes user action code (if any exists) if callAction parameter is true.
Parameters:
valueIndex - the item index
callAction - if true user action code (if any) will be executed

setValues

public void setValues​(java.lang.String[] texts)
Sets the selected text items of the list box (in the multiple-selection mode)
Clears list box selection if texts is null or empty
Doesn't execute user action code
Parameters:
texts - the new selected text items or null

setValues

public void setValues​(java.lang.String[] selectedTexts,
                      boolean callAction)
Sets the selected text items of the list box (in multiple-selection mode) Clears list box selection if texts is null or empty Executes user action code (if any exists) if callAction parameter is true
Parameters:
selectedTexts - the new selected text items or null
callAction - if true user action code (if any exists) will be executed

setValuesIndices

public void setValuesIndices​(int[] valuesIndices)
Selects items with the given indices (in the multiple-selection mode)
Clears list box selection if valuesIndices is null or empty.
Doesn't execute user action code
Parameters:
valuesIndices - the item index

setValuesIndices

public void setValuesIndices​(int[] valuesIndices,
                             boolean callAction)
Selects items with the given indices (in multiple-selection mode) Clears list box selection if valuesIndices is null or empty. Executes user action code (if any exists) if callAction parameter is true.
Parameters:
valuesIndices - the item index
callAction - if true user action code (if any exists) will be executed

getValue

public java.lang.String getValue()
Returns the currently selected text item if in single-selection mode or the first selected text item if in multiple-selection mode Returns null if there is no selection.
Returns:
the currently selected text item (or first one in multiselection)

getValueIndex

public int getValueIndex()
Returns the index of the currently selected text item or -1 when there is no selection. Returns the first selected item if in multiple-selection mode.
Returns:
the index of the currently selected text item or -1

getValues

public java.lang.String[] getValues()
Returns an array of selected text items (for use in multiple-selection mode)
Returns empty array if there is no selection
Returns:
the currently selected text items

getValuesIndices

public int[] getValuesIndices()
Returns an array of selected items' indices (for use in multiple-selection mode). Returns empty array if there is no selection
Returns:
the currently selected items' indices

getItems

public java.lang.String[] getItems()
Returns array of String items currently in this list box. Array of length 0 is returned if there are no items. The returned array should not be changed by user
Returns:
array of String items currently used in this list box

setItems

public void setItems​(java.lang.String[] items)
Sets new items for this list box
This method preserves current list box values if current values are contained in new items.
This method doesn't execute user action code (even if current selection changes).
Note that provided array is used internally and shouldn't be changed by user after this method is called.
Parameters:
items - the array of String items to be placed in this list box

setItems

public void setItems​(java.lang.String[] items,
                     boolean callAction)
Sets new items for this list box. This method preserves current list box values if current values are contained in new items. Note that provided array is used internally and shouldn't be changed by user after this method is called.
Parameters:
items - the array of String items to be placed in the list box
callAction - if true and selection changes, user action code (if any) will be executed

executeUserAction

@AnyLogicInternalAPI
public void executeUserAction​(java.lang.String value)
Description copied from interface: SVGElement
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
executeUserAction in interface SVGElement
Overrides:
executeUserAction in class Shape
How can we improve this article?