1. /*
  2. * @(#)WindowsPopupWindow.java 1.4 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.java.swing.plaf.windows;
  8. import javax.swing.JWindow;
  9. import java.awt.Window;
  10. import java.awt.Graphics;
  11. /**
  12. * A class which tags a window with a particular semantic usage,
  13. * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
  14. * This is used as a temporary solution for getting native AWT support
  15. * for transition effects in Windows 98 and Windows 2000. The native
  16. * code will interpret the windowType property and automatically
  17. * implement appropriate animation when the window is shown/hidden.
  18. * <p>
  19. * Note that support for transition effects may be supported with a
  20. * different mechanism in the future and so this class is
  21. * package-private and targeted for Swing implementation use only.
  22. * <p>
  23. * <strong>Warning:</strong>
  24. * Serialized objects of this class will not be compatible with
  25. * future Swing releases. The current serialization support is appropriate
  26. * for short term storage or RMI between applications running the same
  27. * version of Swing. A future release of Swing will provide support for
  28. * long term persistence.
  29. *
  30. * @version 1.4 01/23/03
  31. * @author Amy Fowler
  32. */
  33. class WindowsPopupWindow extends JWindow {
  34. static final int UNDEFINED_WINDOW_TYPE = 0;
  35. static final int TOOLTIP_WINDOW_TYPE = 1;
  36. static final int MENU_WINDOW_TYPE = 2;
  37. static final int SUBMENU_WINDOW_TYPE = 3;
  38. static final int POPUPMENU_WINDOW_TYPE = 4;
  39. static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
  40. private int windowType;
  41. WindowsPopupWindow(Window parent) {
  42. super(parent);
  43. setFocusableWindowState(false);
  44. }
  45. void setWindowType(int type) {
  46. windowType = type;
  47. }
  48. int getWindowType() {
  49. return windowType;
  50. }
  51. public void update(Graphics g) {
  52. paint(g);
  53. }
  54. public void hide() {
  55. super.hide();
  56. /** We need to call removeNotify() here because hide() does
  57. * something only if Component.visible is true. When the app
  58. * frame is miniaturized, the parent frame of this frame is
  59. * invisible, causing AWT to believe that this frame
  60. * is invisible and causing hide() to do nothing
  61. */
  62. removeNotify();
  63. }
  64. public void show() {
  65. super.show();
  66. this.pack();
  67. }
  68. }