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