- Timestamp:
- 2003-05-27T15:40:47+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/ExclusiveListSelectionListener.java
r4293 r4364 58 58 */ 59 59 public class ExclusiveListSelectionListener 60 61 62 63 64 65 66 60 implements ListSelectionListener { 61 /** A flag set to show that we are already dealing with a list selection change, and to ignore further ones until the flag becomes unset again. */ 62 private boolean ignore = false; 63 /** An array of JList components, containing each JList thats registered with this listener. */ 64 private JList lists[] = null; 65 /** Method to register a new JList with this listener. 66 * @param list The new <strong>JList</strong> to register. 67 67 */ 68 69 70 71 72 73 74 75 76 77 78 79 80 81 68 public void add(JList list) { 69 list.addListSelectionListener(this); 70 if(lists == null) { 71 lists = new JList[1]; 72 lists[0] = list; 73 } 74 else { 75 JList temp[] = new JList[lists.length + 1]; 76 System.arraycopy(lists, 0, temp, 0, lists.length); 77 temp[lists.length] = list; 78 lists = temp; 79 } 80 } 81 /** Any implementation of ListSelectionListener must include this method so we can be informed when the selection changes. In this case we want to clear the selections of all other registered JLists other than the caller. 82 82 * @param event A <strong>ListSelectionEvent</strong> containing informaiton about the event. 83 83 */ 84 85 86 87 88 89 90 91 92 93 94 95 84 public void valueChanged(ListSelectionEvent event) { 85 if(!ignore) { 86 ignore = true; 87 JList source = (JList)event.getSource(); 88 for(int i = 0; i < lists.length; i++) { 89 if(lists[i] != source) { 90 lists[i].clearSelection(); 91 } 92 } 93 ignore = false; 94 } 95 } 96 96 }
Note:
See TracChangeset
for help on using the changeset viewer.