KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > windows > WindowsPopupWindow


1 /*
2  * @(#)WindowsPopupWindow.java 1.5 03/12/19
3  *
4  * Copyright 2004 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
9 import javax.swing.JWindow JavaDoc;
10 import java.awt.Window JavaDoc;
11 import java.awt.Graphics JavaDoc;
12
13 /**
14  * A class which tags a window with a particular semantic usage,
15  * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
16  * This is used as a temporary solution for getting native AWT support
17  * for transition effects in Windows 98 and Windows 2000. The native
18  * code will interpret the windowType property and automatically
19  * implement appropriate animation when the window is shown/hidden.
20  * <p>
21  * Note that support for transition effects may be supported with a
22  * different mechanism in the future and so this class is
23  * package-private and targeted for Swing implementation use only.
24  * <p>
25  * <strong>Warning:</strong>
26  * Serialized objects of this class will not be compatible with
27  * future Swing releases. The current serialization support is appropriate
28  * for short term storage or RMI between applications running the same
29  * version of Swing. A future release of Swing will provide support for
30  * long term persistence.
31  *
32  * @version 1.5 12/19/03
33  * @author Amy Fowler
34  */

35 class WindowsPopupWindow extends JWindow JavaDoc {
36
37     static final int UNDEFINED_WINDOW_TYPE = 0;
38     static final int TOOLTIP_WINDOW_TYPE = 1;
39     static final int MENU_WINDOW_TYPE = 2;
40     static final int SUBMENU_WINDOW_TYPE = 3;
41     static final int POPUPMENU_WINDOW_TYPE = 4;
42     static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
43
44     private int windowType;
45
46     WindowsPopupWindow(Window JavaDoc parent) {
47         super(parent);
48         setFocusableWindowState(false);
49     }
50
51     void setWindowType(int type) {
52         windowType = type;
53     }
54
55     int getWindowType() {
56     return windowType;
57     }
58
59     public void update(Graphics JavaDoc g) {
60         paint(g);
61     }
62
63     public void hide() {
64         super.hide();
65         /** We need to call removeNotify() here because hide() does
66          * something only if Component.visible is true. When the app
67          * frame is miniaturized, the parent frame of this frame is
68          * invisible, causing AWT to believe that this frame
69          * is invisible and causing hide() to do nothing
70          */

71         removeNotify();
72     }
73
74     public void show() {
75     super.show();
76     this.pack();
77     }
78 }
79
Popular Tags