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