1. /*
  2. * @(#)ListSelectionEvent.java 1.15 00/02/02
  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.event;
  11. import java.util.EventObject;
  12. import javax.swing.*;
  13. /**
  14. * An event that characterizes a change in the current
  15. * selection. The change is limited to a row interval.
  16. * ListSelectionListeners will generally query the source of
  17. * the event for the new selected status of each potentially
  18. * changed row.
  19. * <p>
  20. * <strong>Warning:</strong>
  21. * Serialized objects of this class will not be compatible with
  22. * future Swing releases. The current serialization support is appropriate
  23. * for short term storage or RMI between applications running the same
  24. * version of Swing. A future release of Swing will provide support for
  25. * long term persistence.
  26. *
  27. * @version 1.15 02/02/00
  28. * @author Hans Muller
  29. * @author Ray Ryan
  30. * @see ListSelectionModel
  31. */
  32. public class ListSelectionEvent extends EventObject
  33. {
  34. private int firstIndex;
  35. private int lastIndex;
  36. private boolean isAdjusting;
  37. /**
  38. * Represents a change in selection status between firstIndex
  39. * and lastIndex inclusive (firstIndex is less than or equal to
  40. * lastIndex). Atleast one of the rows within the range will
  41. * have changed, a good ListSelectionModel implementation will
  42. * keep the range as small as possible.
  43. *
  44. * @param firstIndex The first index that changed.
  45. * @param lastIndex The last index that changed, lastIndex >= firstIndex.
  46. * @param isAdjusting An indication that this is one of rapid a series of events
  47. */
  48. public ListSelectionEvent(Object source, int firstIndex, int lastIndex,
  49. boolean isAdjusting)
  50. {
  51. super(source);
  52. this.firstIndex = firstIndex;
  53. this.lastIndex = lastIndex;
  54. this.isAdjusting = isAdjusting;
  55. }
  56. /**
  57. * Returns the index of the first row whose selection may have changed.
  58. * @return The first row whose selection value may have changed,
  59. * where zero is the first row
  60. */
  61. public int getFirstIndex() { return firstIndex; }
  62. /**
  63. * Returns the index of the last row whose selection may have changed.
  64. * @return The last row whose selection value may have changed,
  65. * where zero is the first row
  66. */
  67. public int getLastIndex() { return lastIndex; }
  68. /**
  69. * Returns true if this is one of multiple change events.
  70. * @return true if this is one of a rapid series of events
  71. */
  72. public boolean getValueIsAdjusting() { return isAdjusting; }
  73. /**
  74. * Returns a string that displays and identifies this
  75. * object's properties.
  76. *
  77. * @return a String representation of this object
  78. */
  79. public String toString() {
  80. String properties =
  81. " source=" + getSource() +
  82. " firstIndex= " + firstIndex +
  83. " lastIndex= " + lastIndex +
  84. " isAdjusting= " + isAdjusting +
  85. " ";
  86. return getClass().getName() + "[" + properties + "]";
  87. }
  88. }