2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
|
2
|
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
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
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 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
package com.sun.java.swing.plaf.windows;
|
|
26 |
|
|
27 |
import javax.swing.JWindow;
|
|
28 |
import java.awt.Window;
|
|
29 |
import 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 |
*/
|
|
52 |
class 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 |
}
|