Package jltk.gui
Class ListView
- java.lang.Object
-
- jltk.Component
-
- jltk.gui.Control
-
- jltk.gui.ListView
-
public class ListView extends Control
A ListView contains objects line by line events: itemSelected, itemEdited- Version:
- 24.05.2022
- Author:
- ms
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.control.ListView<String>
fxListView
-
Fields inherited from class jltk.Component
fxNode, hasFocus, myWindow, onFocusGained, onFocusLost
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(Object pObject)
Appends pObject to the ListViewvoid
append(Object[] pArray)
Appends the given array of objects to the ListViewvoid
append(String pText)
Appends pText to the ListViewvoid
append(String[] pArray)
Appends the given String array to the ListViewvoid
deselect(int pIndex)
Deselects the item specified by pIndexvoid
deselectAll()
Clears the selection of all selected indices.void
disableEditable()
Makes the LiestView read-onlyvoid
disableMultiselect()
Allows one item to be selected at a time.void
enableEditable()
Makes the ListView editablevoid
enableMultiselect()
Allows one or more items to be selected at a time.String[]
getAllItems()
Return all items as String arrayint
getSelectedIndex()
Returns the index of the selected item (first item has index 0).int[]
getSelectedIndices()
Returns an int array containing all indices of the selected items (first item has index 0).String
getSelectedItem()
Returns the selected item as string.String[]
getSelectedItems()
Return selected items as String arrayint
getSize()
Returns the number of items in this ListView.void
insert(int pIndex, Object pObject)
Inserts the string representation of pObject (.toString()) at the specified position in this ListView.void
insert(int pIndex, String pText)
Inserts pText at the specified position in this ListView.boolean
isSelected(int pIndex)
Returns true, if the given index is currently selected, otherwise false.void
remove(int pIndex)
Remove the item at the specified index (first item has index 0).void
removeAll()
Removes all entries from the ListViewvoid
select(int pIndex)
Selects (highlights) the item specified by pIndexvoid
set(int pIndex, Object pObject)
Replaces the item at the specified position in this ListView with the string representation of pObject (.toString(), first item has index 0).void
set(int pIndex, String pText)
Replaces the item at the specified position in this ListView with pText (first item has index 0).void
setOnItemEdited(String pMethodName)
Set the name of the method, which should be invoke, if the edit of an item of the ListView is comitted.void
setOnItemSelected(String pMethodName)
Set the name of the method, which should be invoke, if an item of the ListView is selected.-
Methods inherited from class jltk.gui.Control
getColor, getHeight, getWidth, init, setColor, setColor, setColor, setHeight, setSize, setTooltip, setWidth
-
Methods inherited from class jltk.Component
activate, deactivate, focus, getX, getY, hasFocus, hide, init, istActive, isVisible, runMethodByName, setOnFocusGained, setOnFocusLost, setPosition, show, toBack, toFront
-
-
-
-
Field Detail
-
fxListView
protected javafx.scene.control.ListView<String> fxListView
-
-
Constructor Detail
-
ListView
public ListView(double pLeft, double pTop, double pWidth, double pHeight)
Create the ListView on the main View- Parameters:
pLeft
- The horizontal coordinatepTop
- The vertical coordinatepWidth
- The width of the combo boxpHeight
- The height of the combo box
-
ListView
public ListView(Window pWindow, double pLeft, double pTop, double pWidth, double pHeight)
Creates the ListView- Parameters:
pLeft
- The horizontal coordinatepTop
- The vertical coordinatepWidth
- The width of the listpHeight
- The height of the listpWindow
- The window, the list should be placed
-
-
Method Detail
-
append
public void append(String pText)
Appends pText to the ListView- Parameters:
pText
- The object to be append.
-
append
public void append(Object pObject)
Appends pObject to the ListView- Parameters:
pObject
- The object to be append.
-
append
public void append(String[] pArray)
Appends the given String array to the ListView- Parameters:
pArray
- a one-dimensiol string array
-
append
public void append(Object[] pArray)
Appends the given array of objects to the ListView- Parameters:
pArray
- a one-dimensiol array
-
insert
public void insert(int pIndex, String pText)
Inserts pText at the specified position in this ListView. Shifts the item currently at that position (if any) and any subsequent item to the bottom (adds one to their indices, first item has index 0).- Parameters:
pText
- The text to be add.
-
insert
public void insert(int pIndex, Object pObject)
Inserts the string representation of pObject (.toString()) at the specified position in this ListView. Shifts the item currently at that position (if any) and any subsequent item to the bottom (adds one to their indices, first item has index 0).- Parameters:
pObject
- The object to add.
-
set
public void set(int pIndex, String pText)
Replaces the item at the specified position in this ListView with pText (first item has index 0).- Parameters:
pText
- The text to be set.
-
set
public void set(int pIndex, Object pObject)
Replaces the item at the specified position in this ListView with the string representation of pObject (.toString(), first item has index 0).- Parameters:
pText
- The object to be set.
-
remove
public void remove(int pIndex)
Remove the item at the specified index (first item has index 0).- Parameters:
pIndex
- the Index of the item, should be removed.
-
removeAll
public void removeAll()
Removes all entries from the ListView
-
select
public void select(int pIndex)
Selects (highlights) the item specified by pIndex- Parameters:
pIndex
-
-
deselect
public void deselect(int pIndex)
Deselects the item specified by pIndex- Parameters:
pIndex
-
-
deselectAll
public void deselectAll()
Clears the selection of all selected indices.
-
isSelected
public boolean isSelected(int pIndex)
Returns true, if the given index is currently selected, otherwise false.- Parameters:
pIndex
- The index to check as to whether it is currently selected or not- Returns:
- True if the given index is selected, false otherwise
-
getSelectedIndex
public int getSelectedIndex()
Returns the index of the selected item (first item has index 0).- Returns:
- The index of the selected item
-
getSelectedIndices
public int[] getSelectedIndices()
Returns an int array containing all indices of the selected items (first item has index 0).- Returns:
- int array with indices of the selected items.
-
getSize
public int getSize()
Returns the number of items in this ListView.- Returns:
- The number of items.
-
getSelectedItem
public String getSelectedItem()
Returns the selected item as string.- Returns:
- The string representation of the item.
-
getSelectedItems
public String[] getSelectedItems()
Return selected items as String array- Returns:
- Selected items as String array
-
getAllItems
public String[] getAllItems()
Return all items as String array- Returns:
- All items as String array
-
setOnItemSelected
public void setOnItemSelected(String pMethodName)
Set the name of the method, which should be invoke, if an item of the ListView is selected.
-
setOnItemEdited
public void setOnItemEdited(String pMethodName)
Set the name of the method, which should be invoke, if the edit of an item of the ListView is comitted.
-
enableMultiselect
public void enableMultiselect()
Allows one or more items to be selected at a time.
-
disableMultiselect
public void disableMultiselect()
Allows one item to be selected at a time.
-
enableEditable
public void enableEditable()
Makes the ListView editable
-
disableEditable
public void disableEditable()
Makes the LiestView read-only
-
-