1. /*
  2. * %W% %E%
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package javax.swing;
  11. import javax.swing.event.*;
  12. /**
  13. * A model that supports at most one indexed selection.
  14. *
  15. * @version %I% %G%
  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. * Sets the model's selected index to <I>index</I>.
  28. *
  29. * Notifies any listeners if the model changes
  30. *
  31. * @param an int specifying the model selection
  32. * @see #getSelectedIndex
  33. * @see #addChangeListener
  34. */
  35. public void setSelectedIndex(int index);
  36. /**
  37. * Clears the selection (to -1).
  38. */
  39. public void clearSelection();
  40. /**
  41. * Returns true if the selection model currently has a selected value.
  42. * @return true if a value is currently selected
  43. */
  44. public boolean isSelected();
  45. /**
  46. * Adds <I>listener</I> as a listener to changes in the model.
  47. * @param l the ChangeListener to add
  48. */
  49. void addChangeListener(ChangeListener listener);
  50. /**
  51. * Removes <I>listener</I> as a listener to changes in the model.
  52. * @param l the ChangeListener to remove
  53. */
  54. void removeChangeListener(ChangeListener listener);
  55. }