KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > SingleSelectionModel


1 /*
2  * @(#)SingleSelectionModel.java 1.19 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing;
9
10 import javax.swing.event.*;
11
12 /**
13  * A model that supports at most one indexed selection.
14  *
15  * @version 1.19 12/19/03
16  * @author Dave Moore
17  */

18 public interface SingleSelectionModel {
19     /**
20      * Returns the model's selection.
21      *
22      * @return the model's selection, or -1 if there is no selection
23      * @see #setSelectedIndex
24      */

25     public int getSelectedIndex();
26
27     /**
28      * Sets the model's selected index to <I>index</I>.
29      *
30      * Notifies any listeners if the model changes
31      *
32      * @param index an int specifying the model selection
33      * @see #getSelectedIndex
34      * @see #addChangeListener
35      */

36     public void setSelectedIndex(int index);
37
38     /**
39      * Clears the selection (to -1).
40      */

41     public void clearSelection();
42
43     /**
44      * Returns true if the selection model currently has a selected value.
45      * @return true if a value is currently selected
46      */

47     public boolean isSelected();
48
49     /**
50      * Adds <I>listener</I> as a listener to changes in the model.
51      * @param listener the ChangeListener to add
52      */

53     void addChangeListener(ChangeListener listener);
54
55     /**
56      * Removes <I>listener</I> as a listener to changes in the model.
57      * @param listener the ChangeListener to remove
58      */

59     void removeChangeListener(ChangeListener listener);
60 }
61
Popular Tags