1. /*
  2. * @(#)ListDataEvent.java 1.10 01/11/29
  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.event;
  8. import java.util.EventObject;
  9. /**
  10. * Defines an event that encapsulates changes to a list.
  11. * <p>
  12. * <strong>Warning:</strong>
  13. * Serialized objects of this class will not be compatible with
  14. * future Swing releases. The current serialization support is appropriate
  15. * for short term storage or RMI between applications running the same
  16. * version of Swing. A future release of Swing will provide support for
  17. * long term persistence.
  18. *
  19. * @version 1.10 11/29/01
  20. * @author Hans Muller
  21. */
  22. public class ListDataEvent extends EventObject
  23. {
  24. /** Identifies one or more changes in the lists contents. */
  25. public static final int CONTENTS_CHANGED = 0;
  26. /** Identifies the addition of one or more contiguous items to the list */
  27. public static final int INTERVAL_ADDED = 1;
  28. /** Identifies the removal of one or more contiguous items from the list */
  29. public static final int INTERVAL_REMOVED = 2;
  30. private int type;
  31. private int index0;
  32. private int index1;
  33. /**
  34. * Returns the event type. The possible values are:
  35. * <ul>
  36. * <li> {@link CONTENTS_CHANGED}
  37. * <li> {@link INTERVAL_ADDED}
  38. * <li> {@link INTERVAL_REMOVED}
  39. * </ul>
  40. *
  41. * @return an int representing the type value
  42. */
  43. public int getType() { return type; }
  44. /**
  45. * Returns the lower index of the range. For a single
  46. * element, this value is the same as that returned by {@link #getIndex1}.
  47. *
  48. * @return an int representing the lower index value
  49. */
  50. public int getIndex0() { return index0; }
  51. /**
  52. * Returns the upper index of the range. For a single
  53. * element, this value is the same as that returned by {@link #getIndex0}.
  54. *
  55. * @return an int representing the upper index value
  56. */
  57. public int getIndex1() { return index1; }
  58. /**
  59. * Constructs a ListDataEvent object.
  60. *
  61. * @param source the source Object (typically <code>this</code>)
  62. * @param type an int specifying {@link CONTENTS_CHANGED},
  63. * {@link INTERVAL_ADDED}, or {@link INTERVAL_REMOVED}
  64. * @param index0 an int specifying the bottom of a range
  65. * @param index1 an int specifying the top of a range
  66. */
  67. public ListDataEvent(Object source, int type, int index0, int index1) {
  68. super(source);
  69. this.type = type;
  70. this.index0 = index0;
  71. this.index1 = index1;
  72. }
  73. }