1. /*
  2. * @(#)InternalFrameEvent.java 1.11 00/02/02
  3. *
  4. * Copyright 1998-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.awt.AWTEvent;
  12. import javax.swing.JInternalFrame;
  13. /**
  14. * InternalFrameEvent: an AWTEvent which adds support for
  15. * JInternalFrame objects as the event source. This class has the
  16. * same event types as WindowEvent, although different ids are used.
  17. * <p>
  18. * <strong>Warning:</strong>
  19. * Serialized objects of this class will not be compatible with
  20. * future Swing releases. The current serialization support is appropriate
  21. * for short term storage or RMI between applications running the same
  22. * version of Swing. A future release of Swing will provide support for
  23. * long term persistence.
  24. *
  25. * @see java.awt.event.WindowEvent
  26. * @see java.awt.event.WindowListener
  27. * @version 1.11 02/02/00
  28. * @author Thomas Ball
  29. */
  30. public class InternalFrameEvent extends AWTEvent {
  31. /**
  32. * The first number in the range of ids used for window events.
  33. */
  34. public static final int INTERNAL_FRAME_FIRST = 25549;
  35. /**
  36. * The last number in the range of ids used for window events.
  37. */
  38. public static final int INTERNAL_FRAME_LAST = 25555;
  39. /**
  40. * The window opened event. This event is delivered only
  41. * the first time a window is made visible.
  42. */
  43. public static final int INTERNAL_FRAME_OPENED = INTERNAL_FRAME_FIRST;
  44. /**
  45. * The "window is closing" event. This event is delivered when
  46. * the user selects "Quit" from the window's system menu. If
  47. * the program does not explicitly hide or destroy the window as
  48. * while processing this event, the window close operation will be
  49. * canceled.
  50. */
  51. public static final int INTERNAL_FRAME_CLOSING = 1 + INTERNAL_FRAME_FIRST;
  52. /**
  53. * The window closed event. This event is delivered after
  54. * the window has been closed as the result of a call to hide or
  55. * destroy.
  56. */
  57. public static final int INTERNAL_FRAME_CLOSED = 2 + INTERNAL_FRAME_FIRST;
  58. /**
  59. * The window iconified event. This event indicates that the window
  60. * was shrunk down to a small icon.
  61. */
  62. public static final int INTERNAL_FRAME_ICONIFIED = 3 + INTERNAL_FRAME_FIRST;
  63. /**
  64. * The window deiconified event type. This event indicates that the
  65. * window has been restored to its normal size.
  66. */
  67. public static final int INTERNAL_FRAME_DEICONIFIED = 4 + INTERNAL_FRAME_FIRST;
  68. /**
  69. * The window activated event type. This event indicates that keystrokes
  70. * and mouse clicks are directed towards this window.
  71. */
  72. public static final int INTERNAL_FRAME_ACTIVATED = 5 + INTERNAL_FRAME_FIRST;
  73. /**
  74. * The window deactivated event type. This event indicates that keystrokes
  75. * and mouse clicks are no longer directed to the window.
  76. */
  77. public static final int INTERNAL_FRAME_DEACTIVATED = 6 + INTERNAL_FRAME_FIRST;
  78. /**
  79. * Constructs a InternalFrameEvent object.
  80. * @param source the JInternalFrame object that originated the event
  81. * @param id an integer indicating the type of event
  82. */
  83. public InternalFrameEvent(JInternalFrame source, int id) {
  84. super(source, id);
  85. }
  86. /**
  87. * Returns a parameter string identifying this event.
  88. * This method is useful for event-logging and for debugging.
  89. *
  90. * @return a string identifying the event and its attributes
  91. */
  92. public String paramString() {
  93. String typeStr;
  94. switch(id) {
  95. case INTERNAL_FRAME_OPENED:
  96. typeStr = "INTERNAL_FRAME_OPENED";
  97. break;
  98. case INTERNAL_FRAME_CLOSING:
  99. typeStr = "INTERNAL_FRAME_CLOSING";
  100. break;
  101. case INTERNAL_FRAME_CLOSED:
  102. typeStr = "INTERNAL_FRAME_CLOSED";
  103. break;
  104. case INTERNAL_FRAME_ICONIFIED:
  105. typeStr = "INTERNAL_FRAME_ICONIFIED";
  106. break;
  107. case INTERNAL_FRAME_DEICONIFIED:
  108. typeStr = "INTERNAL_FRAME_DEICONIFIED";
  109. break;
  110. case INTERNAL_FRAME_ACTIVATED:
  111. typeStr = "INTERNAL_FRAME_ACTIVATED";
  112. break;
  113. case INTERNAL_FRAME_DEACTIVATED:
  114. typeStr = "INTERNAL_FRAME_DEACTIVATED";
  115. break;
  116. default:
  117. typeStr = "unknown type";
  118. }
  119. return typeStr;
  120. }
  121. /**
  122. * Returns the originator of the event.
  123. *
  124. * @return the JInternalFrame object that originated the event
  125. * @since 1.3
  126. */
  127. public JInternalFrame getInternalFrame () {
  128. return (source instanceof JInternalFrame)? (JInternalFrame)source : null;
  129. }
  130. }