0% found this document useful (0 votes)
8 views1 page

List Control Tuition Notes

Uploaded by

neelshingavi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

List Control Tuition Notes

Uploaded by

neelshingavi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

List control

The list class provides a compact, multiple choice, schrolling selection


list. unlike the choice object, which shows only a single selected item, a list
object can be constructed to show any number of choices in the visible window. it
can also be created to allow multiple selections.
Syntax: 1. List()
2. List(int nor)
3. List(int nor, Boolean multiselect)

To add the selection to the list, call


void add(String name);
void add(String name, int Index);

You can specify -1 to add the item to the end of the list.
You can determine which item is currently selected by calling
String getSelectedItem();
int getSelectedIndex();

If no selection has been made yet, it returns -1 [ getSelectedIndex() ]


for the list that allow multiple selections use either
getSelectedItems() or
getSelectedIndexes()
Syntax: String [ getSelectedItems() ]
int [ getSelectedIndexes() ]

To obtain no. of items in the list call


int getItemCount()

you can set the currently selected items by using


void select(int index);

you can obtain the item at specific index by calling


String getItem( int Index );

List control can occur action event as well as item event so you must define
actionPerformed() and itemStateChanged()
The getActionCommand() can be used to retrieve the item which is newly selected.
The getStateChange() is used to determine whether the selection or deselection
triggered this event.
The getItemSelectable() returns reference to the object that triggered this event

You might also like