1. /*
  2. * @(#)AdjustmentEvent.java 1.21 00/02/02
  3. *
  4. * Copyright 1996-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 java.awt.event;
  11. import java.awt.Adjustable;
  12. import java.awt.AWTEvent;
  13. import java.awt.Event;
  14. /**
  15. * The adjustment event emitted by Adjustable objects.
  16. * @see java.awt.Adjustable
  17. * @see AdjustmentListener
  18. *
  19. * @author Amy Fowler
  20. * @version 1.21 02/02/00
  21. * @since 1.1
  22. */
  23. public class AdjustmentEvent extends AWTEvent {
  24. /**
  25. * Marks the first integer id for the range of adjustment event ids.
  26. */
  27. public static final int ADJUSTMENT_FIRST = 601;
  28. /**
  29. * Marks the last integer id for the range of adjustment event ids.
  30. */
  31. public static final int ADJUSTMENT_LAST = 601;
  32. /**
  33. * The adjustment value changed event.
  34. */
  35. public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP
  36. /**
  37. * The unit increment adjustment type.
  38. */
  39. public static final int UNIT_INCREMENT = 1;
  40. /**
  41. * The unit decrement adjustment type.
  42. */
  43. public static final int UNIT_DECREMENT = 2;
  44. /**
  45. * The block decrement adjustment type.
  46. */
  47. public static final int BLOCK_DECREMENT = 3;
  48. /**
  49. * The block increment adjustment type.
  50. */
  51. public static final int BLOCK_INCREMENT = 4;
  52. /**
  53. * The absolute tracking adjustment type.
  54. */
  55. public static final int TRACK = 5;
  56. /**
  57. * The adjustable object that fired the event.
  58. *
  59. * @serial
  60. * @see getAdjustable()
  61. */
  62. Adjustable adjustable;
  63. /**
  64. * <code>value</code> will contain the new value of the
  65. * adjustable object. This value will always be in a
  66. * range associated adjustable object.
  67. *
  68. * @serial
  69. * @see getValue()
  70. */
  71. int value;
  72. /**
  73. * The <code>adjustmentType</code> describes how the adjustable
  74. * object value has changed.
  75. * This value can be increased/decreased by a block or unit amount
  76. * where the block is associated with page increments/decrements,
  77. * and a unit is associated with line increments/decrements.
  78. *
  79. * @serial
  80. * @see getAdjustmentType()
  81. */
  82. int adjustmentType;
  83. /*
  84. * JDK 1.1 serialVersionUID
  85. */
  86. private static final long serialVersionUID = 5700290645205279921L;
  87. /**
  88. * Constructs a AdjustmentEvent object with the specified Adjustable
  89. * source, event type, adjustment type, and value.
  90. * type, and value.
  91. * @param source the Adjustable object where the event originated
  92. * @param id the event type
  93. * @param type the adjustment type
  94. * @param value the current value of the adjustment
  95. */
  96. public AdjustmentEvent(Adjustable source, int id, int type, int value) {
  97. super(source, id);
  98. adjustable = source;
  99. this.adjustmentType = type;
  100. this.value = value;
  101. }
  102. /**
  103. * Returns the Adjustable object where this event originated.
  104. */
  105. public Adjustable getAdjustable() {
  106. return adjustable;
  107. }
  108. /**
  109. * Returns the current value in the adjustment event.
  110. */
  111. public int getValue() {
  112. return value;
  113. }
  114. /**
  115. * Returns the type of adjustment which caused the value changed
  116. * event.
  117. * @see #UNIT_INCREMENT
  118. * @see #UNIT_DECREMENT
  119. * @see #BLOCK_INCREMENT
  120. * @see #BLOCK_DECREMENT
  121. * @see #TRACK
  122. */
  123. public int getAdjustmentType() {
  124. return adjustmentType;
  125. }
  126. public String paramString() {
  127. String typeStr;
  128. switch(id) {
  129. case ADJUSTMENT_VALUE_CHANGED:
  130. typeStr = "ADJUSTMENT_VALUE_CHANGED";
  131. break;
  132. default:
  133. typeStr = "unknown type";
  134. }
  135. String adjTypeStr;
  136. switch(adjustmentType) {
  137. case UNIT_INCREMENT:
  138. adjTypeStr = "UNIT_INCREMENT";
  139. break;
  140. case UNIT_DECREMENT:
  141. adjTypeStr = "UNIT_DECREMENT";
  142. break;
  143. case BLOCK_INCREMENT:
  144. adjTypeStr = "BLOCK_INCREMENT";
  145. break;
  146. case BLOCK_DECREMENT:
  147. adjTypeStr = "BLOCK_DECREMENT";
  148. break;
  149. case TRACK:
  150. adjTypeStr = "TRACK";
  151. break;
  152. default:
  153. adjTypeStr = "unknown type";
  154. }
  155. return typeStr + ",adjType="+adjTypeStr + ",value="+value;
  156. }
  157. }