CheckedListBox Class

CheckedListBox Class

This Package | All Packages

ListBox
  |
  +--CheckedListBox
public class CheckedListBox
extends ListBox

Provides an extension of the regular ListBox class that adds events and methods for checked list box functionality.

Constructors
Name Description
CheckedListBox() Creates a new CheckedListBox.

Methods
Name Description
addItem(Object item, int check) Adds an item to the list box with the given initial value for the checked portion of the item.
addOnItemCheck(ItemCheckEventHandler value) Topic under construction.
getCheckedIndices() Retrieves an array that contains the indices of checked items.
getCheckOnClick() Retrieves a boolean value that indicates whether the checkbox state is toggled when an item is selected.
getItemCheck(int index) Retrieves a value that identifies the checked state of the specified item.
getItemChecked(int index) Retrieves a Boolean value that indicates whether the specified item is checked.
getOnItemCheck() Retrieves the current recipient of the OnItemCheck event.
getThreeDCheckBoxes() Indicates whether the check boxes should have a flat or three-dimensional appearance.
insert(int index, Object item, int check) Adds a new item to the internal array of items with the given checked state.
insert(int index, Object item) Adds a new item marked as unchecked.
removeAll() Removes all items from the list box.
removeOnItemCheck(ItemCheckEventHandler value) Removes the given handler for the "OnItemCheck" event.
setCheckOnClick(boolean value) Specifies whether the checkbox should be toggled when an item is selected.
setItemCheck(int index, int value) Sets the checked state of the specified item.
setSelectionStyle(int value) Specifies the type of selection permitted with this list box.
setThreeDCheckBoxes(boolean threed) Determines whether the check boxes should have a flat or three-dimensional appearance.

Constructors

CheckedListBox.CheckedListBox

Syntax
public CheckedListBox();
Description

Creates a new CheckedListBox.

Methods

CheckedListBox.addItem

Syntax
public void addItem( Object item, int check );
Parameters
item
The new item to add to the end of the list box.
check
The initial state for the checked portion of the item.
Description

Adds an item to the list box with the given initial value for the checked portion of the item.

CheckedListBox.addOnItemCheck

Syntax
public void addOnItemCheck( ItemCheckEventHandler value );
Description

Topic under construction.

CheckedListBox.getCheckedIndices

Syntax
public final int [] getCheckedIndices();
Return Value

Returns an array that contains the indices of checked items.

Description

Retrieves an array that contains the indices of checked items.

CheckedListBox.getCheckOnClick

Syntax
public final boolean getCheckOnClick();
Return Value

Returns boolean false, if two clicks are required to toggle checkbox state; otherwise, returns true.

Description

Retrieves a boolean value that indicates whether the checkbox state is toggled when an item is selected. By default, a click on a listbox item selects the item, and a second click toggles the checkbox state.

CheckedListBox.getItemCheck

Syntax
public final int getItemCheck( int index );
Parameters
index
The index of the item.
Return Value

Returns one of the enumeration constants defined in the CheckState class. This value indicates the current checked state of the specified item.

Description

Retrieves a value that identifies the checked state of the specified item.

CheckedListBox.getItemChecked

Syntax
public final boolean getItemChecked( int index );
Parameters
index
The index of the item.
Return Value

Returns true if the item is checked; otherwise, returns false.

Description

Retrieves a Boolean value that indicates whether the specified item is checked.

CheckedListBox.getOnItemCheck

Syntax
public ItemCheckEventHandler getOnItemCheck();
Return Value

Returns the current listener on this event.

Description

Retrieves the current recipient of the OnItemCheck event.

CheckedListBox.getThreeDCheckBoxes

Syntax
public boolean getThreeDCheckBoxes();
Return Value

Returns true if the appearance is three-dimensional, or returns false if the appearance is flat.

Description

Indicates whether the check boxes should have a flat or three-dimensional appearance.

CheckedListBox.insert

Syntax 1
protected void insert( int index, Object item, int check );
Parameters
index
The index at which to insert the item.
item
The value of the item to save.
check
The initial checked state for the item.
Description

Adds a new item to the internal array of items with the given checked state. These are maintained outside of Win32 because of marshalling issues.



Syntax 2
protected void insert( int index, Object item );
Parameters
index
The index at which to insert the item.
item
The item to insert.
Description

Adds a new item marked as unchecked.

CheckedListBox.removeAll

Syntax
public final void removeAll();
Description

Removes all items from the list box. All values and item data are lost.

CheckedListBox.removeOnItemCheck

Syntax
public final void removeOnItemCheck( ItemCheckEventHandler value );
Parameters
value
Event handler to be removed.
Description

Removes the given handler for the "OnItemCheck" event. If there are duplicate entries, ALL are removed.

CheckedListBox.setCheckOnClick

Syntax
public final void setCheckOnClick( boolean value );
Parameters
value
If true, the listbox items will be checked when they are clicked. Otherwise, the items must be clicked twice to be checked.
Description

Specifies whether the checkbox should be toggled when an item is selected. The default behaviour of the CheckedListBox selects the item when the user clicks it, then checks the item when the user clicks a second time.

CheckedListBox.setItemCheck

Syntax
public final void setItemCheck( int index, int value );
Parameters
index
Index of the item for which to set the checked state.
value
New value for displaying a check. This must be one of the values defined in the CheckState enumeration.
Description

Sets the checked state of the specified item.

CheckedListBox.setSelectionStyle

Syntax
public final void setSelectionStyle( int value );
Parameters
value
One of the constants defined in the SelectionStyle enumeration.
Description

Specifies the type of selection permitted with this list box. Multiple selections are not supported for checked list boxes; you can select one item or none.

CheckedListBox.setThreeDCheckBoxes

Syntax
public void setThreeDCheckBoxes( boolean threed );
Parameters
threed
Set to true for a three-dimensional appearance; set to false for a flat appearance.
Description

Determines whether the check boxes should have a flat or three-dimensional appearance.