1. /*
  2. * %W% %E%
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing;
  8. import javax.swing.event.*;
  9. /**
  10. * A model that supports at most one indexed selection.
  11. *
  12. * @version %I% %G%
  13. * @author Dave Moore
  14. */
  15. public interface SingleSelectionModel {
  16. /**
  17. * Returns the model's selection.
  18. *
  19. * @return the model's selection, or -1 if there is no selection
  20. * @see #setSelectedIndex
  21. */
  22. public int getSelectedIndex();
  23. /**
  24. * Sets the model's selected index to <I>index</I>.
  25. *
  26. * Notifies any listeners if the model changes
  27. *
  28. * @param an int specifying the model selection
  29. * @see #getSelectedIndex
  30. * @see #addChangeListener
  31. */
  32. public void setSelectedIndex(int index);
  33. /**
  34. * Clears the selection (to -1).
  35. */
  36. public void clearSelection();
  37. /**
  38. * Returns true if the selection model currently has a selected value.
  39. * @return true if a value is currently selected
  40. */
  41. public boolean isSelected();
  42. /**
  43. * Adds <I>listener</I> as a listener to changes in the model.
  44. * @param l the ChangeListener to add
  45. */
  46. void addChangeListener(ChangeListener listener);
  47. /**
  48. * Removes <I>listener</I> as a listener to changes in the model.
  49. * @param l the ChangeListener to remove
  50. */
  51. void removeChangeListener(ChangeListener listener);
  52. }