jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsPopupWindow.java
author rupashka
Thu, 16 Feb 2012 17:42:09 +0400
changeset 11975 d3620e28371c
parent 5506 202f599c92aa
child 23632 cd7a34d12e8c
permissions -rw-r--r--
7089914: Focus on image icons are not visible in javaws cache with high contrast mode Reviewed-by: rupashka Contributed-by: Sean Chou <zhouyx@linux.vnet.ibm.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package com.sun.java.swing.plaf.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.swing.JWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.Window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.Graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A class which tags a window with a particular semantic usage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This is used as a temporary solution for getting native AWT support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * for transition effects in Windows 98 and Windows 2000.  The native
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * code will interpret the windowType property and automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * implement appropriate animation when the window is shown/hidden.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Note that support for transition effects may be supported with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * different mechanism in the future and so this class is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * package-private and targeted for Swing implementation use only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * future Swing releases.  The current serialization support is appropriate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * for short term storage or RMI between applications running the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * version of Swing.  A future release of Swing will provide support for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * long term persistence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @author Amy Fowler
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
class WindowsPopupWindow extends JWindow {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    static final int UNDEFINED_WINDOW_TYPE      = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    static final int TOOLTIP_WINDOW_TYPE        = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static final int MENU_WINDOW_TYPE           = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static final int SUBMENU_WINDOW_TYPE        = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    static final int POPUPMENU_WINDOW_TYPE      = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private int windowType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    WindowsPopupWindow(Window parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        super(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        setFocusableWindowState(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    void setWindowType(int type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        windowType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    int getWindowType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return windowType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    public void update(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public void hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        /** We need to call removeNotify() here because hide() does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
         * something only if Component.visible is true. When the app
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
         * frame is miniaturized, the parent frame of this frame is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
         * invisible, causing AWT to believe that this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
         *  is invisible and causing hide() to do nothing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public void show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        super.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        this.pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
}