Package com.jidesoft.swing
Class DefaultSelectable
java.lang.Object
com.jidesoft.swing.DefaultSelectable
- All Implemented Interfaces:
Selectable
The element used by CheckBoxList's ListModel. In order to allow check box in JList without messing up when list model
changes, we use this class to store the object itself and a boolean to indicated if the row is selected.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSelectable(Object object) Creates CheckBoxListElement with an actual object. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the actual element.inthashCode()Overrides to consider the hash code of the object only.voidInverts the selection status.booleanChecks if selection change is allowed.booleanGets the selected status.voidsetEnabled(boolean enabled) Enabled selection change.voidSets the actual element.voidsetSelected(boolean selected) Sets it as selected.toString()Overrides to consider the toString() of object only.
-
Field Details
-
_object
-
_selected
protected boolean _selected -
_enabled
protected boolean _enabled
-
-
Constructor Details
-
DefaultSelectable
Creates CheckBoxListElement with an actual object. In the case of CheckBoxList, instead of add the object directly to ListModel, you should wrap it in CheckBoxListElement and add CheckBoxListElement into ListModel.- Parameters:
object- the actual object
-
-
Method Details
-
setObject
Sets the actual element.- Parameters:
object-
-
getObject
Gets the actual element.- Returns:
- the actual element.
-
setSelected
public void setSelected(boolean selected) Sets it as selected.- Specified by:
setSelectedin interfaceSelectable- Parameters:
selected-
-
invertSelected
public void invertSelected()Inverts the selection status.- Specified by:
invertSelectedin interfaceSelectable
-
isSelected
public boolean isSelected()Gets the selected status.- Specified by:
isSelectedin interfaceSelectable- Returns:
- true if it is selected. Otherwise, false.
-
setEnabled
public void setEnabled(boolean enabled) Enabled selection change. Enabled false doesn't mean selected is false. If it is selected before, setEnable(false) won't make selected become false. In the other word, setEnabled won't change the the value of isSelected().- Specified by:
setEnabledin interfaceSelectable- Parameters:
enabled-
-
isEnabled
public boolean isEnabled()Checks if selection change is allowed.- Specified by:
isEnabledin interfaceSelectable- Returns:
- true if selection change is allowed.
-
hashCode
public int hashCode()Overrides to consider the hash code of the object only. From outside point of view, this class should behave just like object itself. That's why we override hashCode. -
toString
Overrides to consider the toString() of object only. From outside point of view, this class should behave just like object itself. That's why we override toString. -
equals
-