How to Write a List Selection Listener
by, 04-26-2012 at 09:37 PM (1776 Views)
When selection of table or list is changed or is changing, then list selection event takes place. From an object, these list selection events get fired which result in implementation of interface ListSelectionModel. To get the list selection model of the table, either use getColumnModel().getSelectionModel() or getSelectionModel method.
For detection of the list selection events, register listener at the list selection model which is appropriate. An option to register the listener is also given at the list instead of list selection model directly.
Two examples have been given in this section to show that how a list selection event could be listened at a selection model. Examples in which list selection listeners is used list the examples which listen directly at the list.
Selection mode could be changed dynamically to any of these given modes.
• “Single interval” selection mode.
• “Single” selection mode.
• “Multiple interval” selection mode.