Package jltk.gui
Class ComboBox
- java.lang.Object
-
- jltk.Component
-
- jltk.gui.Control
-
- jltk.gui.ComboBox
-
public class ComboBox extends Control
A Combobox holds different entries. One entry can be select. events: itemSelected- Version:
- 10.4.2022
- Author:
- ms
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.control.ComboBox
fxComboBox
-
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
add(int pIndex, Object pObject)
Insert pObject at the specified position in this combobox.void
add(int pIndex, String pText)
Insert pText at the specified position in this combobox.void
append(Object pObject)
Append pObject to the Comboboxvoid
append(String pText)
Append pText to the Comboboxvoid
clear()
Remove all entries from the comboboxvoid
clearSelection()
Clears the selection of all selected indices.void
deselect(int pIndex)
Deselects the item specified by pIndexint
getSelectedIndex()
Returns the index of the selected item (first item has index 0).Object
getSelectedItem()
Returns the selected item as object.String
getSelectedItemAsText()
Returns the selected item as string.int
getSize()
Returns the number of items in this combobox.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
select(int pIndex)
Selects (highlights) the item specified by pIndexvoid
set(int pIndex, Object pObject)
Replace the item at the specified position in this combobox with pObject (first item has index 0).void
set(int pIndex, String pText)
Replace the item at the specified position in this combobox with pText (first item has index 0).void
setOnItemSelected(String pMethodName)
Sets the name of the method, which should be invoke, if an item of the combobox 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
-
-
-
-
Constructor Detail
-
ComboBox
public ComboBox(double pLeft, double pTop, double pWidth, double pHeight)
Create the ComboBox. Put it on the window and set the actionlistener.- Parameters:
pLeft
- The horizontal coordinatepTop
- The vertical coordinatepWidth
- The width of the combo boxpHeight
- The height of the combo box
-
ComboBox
public ComboBox(Window pWindow, double pLeft, double pTop, double pWidth, double pHeight)
Create the combo box- Parameters:
pLeft
- The horizontal coordinatepTop
- The vertical coordinatepWidth
- The width of the combo boxpHeight
- The height of the combo boxpWindow
- The window, the combo box should be placedpText
- The label of the combo box
-
-
Method Detail
-
append
public void append(String pText)
Append pText to the Combobox- Parameters:
pText
- The object to be append.
-
append
public void append(Object pObject)
Append pObject to the Combobox- Parameters:
pObject
- The object to be append.
-
add
public void add(int pIndex, String pText)
Insert pText at the specified position in this combobox. 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.
-
add
public void add(int pIndex, Object pObject)
Insert pObject at the specified position in this combobox. 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)
Replace the item at the specified position in this combobox with pText (first item has index 0).- Parameters:
pText
- The text to be set.
-
set
public void set(int pIndex, Object pObject)
Replace the item at the specified position in this combobox with pObject (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.
-
clear
public void clear()
Remove all entries from the combobox
-
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
-
-
clearSelection
public void clearSelection()
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
-
getSelectedItem
public Object getSelectedItem()
Returns the selected item as object.- Returns:
- The selected item
-
getSize
public int getSize()
Returns the number of items in this combobox.- Returns:
- The number of items.
-
getSelectedItemAsText
public String getSelectedItemAsText()
Returns the selected item as string.- Returns:
- The string representation of the item.
-
setOnItemSelected
public void setOnItemSelected(String pMethodName)
Sets the name of the method, which should be invoke, if an item of the combobox is selected.
-
-