KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > SelectionModelEvent


1 /*
2  * $Id: SelectionModelEvent.java,v 1.1 2005/02/24 20:35:30 rbair Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7 package org.jdesktop.swing.data;
8
9 import java.util.EventObject JavaDoc;
10
11 /**
12  * Event for tracking changes in the selected rows in a SelectionModel
13  * @author Richard Bair
14  */

15 public class SelectionModelEvent extends EventObject JavaDoc {
16     /**
17      * The first index in the range of indexes. Must be >= 0.
18      */

19     private int firstIndex;
20     /**
21      * The last index in the range of indexes. firstIndex<=lastIndex
22      */

23     private int lastIndex;
24     
25     /**
26      * Create a new SelectionModelEvent. The range between firstIndex and lastIndex
27      * inclusive (firstIndex is less than or equal to lastIndex) represents a change
28      * in selection state of those rows. At least one of the rows within the range
29      * will have changed. A good SelectionModel implementation will keep the range
30      * as small as possible.
31      * @param source the SelectionModel that fired this event
32      * @param firstIndex the first index that changed
33      * @param lastIndex the last index that changed, lastIndex >= firstIndex
34      */

35     public SelectionModelEvent(SelectionModel source, int firstIndex, int lastIndex) {
36         super(source);
37         assert(firstIndex <= lastIndex);
38         assert(firstIndex >= 0);
39         this.firstIndex = firstIndex;
40         this.lastIndex = lastIndex;
41     }
42     
43     /**
44      * @return the first row whose selection value may have changed, where zero is the
45      * first row
46      */

47     public int getFirstIndex() {
48         return firstIndex;
49     }
50     
51     /**
52      * @return the last row whose selection value may have changed, where zero is the
53      * last row
54      */

55     public int getLastIndex() {
56         return lastIndex;
57     }
58 }
59
Popular Tags