ItemListener Interface
Package: java.awt
ItemListener is the interface that must be implemented by classes that will handle item events that are raised when the user selects an item in a list box or combo box control.
Method
|
Method |
Description |
|
|
This method is invoked when an action is performed on a control with which this class is registered as an action event listener. |
Here’s an example of a class that implements ItemListener:
private class MyItemListener
implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
// code to handle item event
}
}
To register this class with a list control named list1, use a statement like this:
list1.addItemListener(new MyItemListener());
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
