Currently, I have a JList listen to list selection listener.
private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {
// When the user release the mouse button and completes the selection,
// getValueIsAdjusting() becomes false
if (evt.getValueIsAdjusting()) {
/*
In certain situation, I may want to prevent user from selecting other
than current selection. How can I do so?
*/
}
}
In certain situation, I may want to prevent user from selecting other than current selection. How can I do so?
It seems too late when I receive ListSelectionEvent. But, if I want to do it before ListSelectionEvent happen, I do not know that user is trying to select other.
Here is one of the senario.
The JList is contains list of project name. So, whenever user select new list item, we need to turn the View, from current project, and display new project. However, current project may be unsaved yet. Hence, if current project unsaved yet, we will ask for user confirmation, "Save Project?" (Yes, No, Cancel) When user select cancel, this means he want to cancel his "select to another project" action. He want to stick with current JList selection. We will pop up the confirmation dialog box in jList1ValueChanged event handle. But when we try to stick with current JList selection, it is already too late.