blob: 774ac39155615f432c0e197b80cfdb0ded7f449a [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2001-2002 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25package com.sun.java.swing.plaf.windows;
26
27import javax.swing.JWindow;
28import java.awt.Window;
29import java.awt.Graphics;
30
31/**
32 * A class which tags a window with a particular semantic usage,
33 * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
34 * This is used as a temporary solution for getting native AWT support
35 * for transition effects in Windows 98 and Windows 2000. The native
36 * code will interpret the windowType property and automatically
37 * implement appropriate animation when the window is shown/hidden.
38 * <p>
39 * Note that support for transition effects may be supported with a
40 * different mechanism in the future and so this class is
41 * package-private and targeted for Swing implementation use only.
42 * <p>
43 * <strong>Warning:</strong>
44 * Serialized objects of this class will not be compatible with
45 * future Swing releases. The current serialization support is appropriate
46 * for short term storage or RMI between applications running the same
47 * version of Swing. A future release of Swing will provide support for
48 * long term persistence.
49 *
50 * @author Amy Fowler
51 */
52class WindowsPopupWindow extends JWindow {
53
54 static final int UNDEFINED_WINDOW_TYPE = 0;
55 static final int TOOLTIP_WINDOW_TYPE = 1;
56 static final int MENU_WINDOW_TYPE = 2;
57 static final int SUBMENU_WINDOW_TYPE = 3;
58 static final int POPUPMENU_WINDOW_TYPE = 4;
59 static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
60
61 private int windowType;
62
63 WindowsPopupWindow(Window parent) {
64 super(parent);
65 setFocusableWindowState(false);
66 }
67
68 void setWindowType(int type) {
69 windowType = type;
70 }
71
72 int getWindowType() {
73 return windowType;
74 }
75
76 public void update(Graphics g) {
77 paint(g);
78 }
79
80 public void hide() {
81 super.hide();
82 /** We need to call removeNotify() here because hide() does
83 * something only if Component.visible is true. When the app
84 * frame is miniaturized, the parent frame of this frame is
85 * invisible, causing AWT to believe that this frame
86 * is invisible and causing hide() to do nothing
87 */
88 removeNotify();
89 }
90
91 public void show() {
92 super.show();
93 this.pack();
94 }
95}