jdk/test/javax/swing/JPopupMenu/8147521/PopupMenuTest.java
author rchamyal
Thu, 26 May 2016 16:02:19 +0530
changeset 39001 d446b5342c35
child 39027 60fc2577ef28
permissions -rw-r--r--
8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup Reviewed-by: alexsch, serb, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39001
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     1
/*
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     4
 *
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     8
 *
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    13
 * accompanied this code).
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    14
 *
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    18
 *
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    21
 * questions.
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    22
 */
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    23
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    24
/*
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    25
 * @test
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    26
 * @bug 8147521
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    27
 * @summary [macosx] Internal API Usage: setPopupType used to force creation of
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    28
 *  heavyweight popup
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    29
 * @run main PopupMenuTest
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    30
 */
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    31
import java.awt.Component;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    32
import java.awt.Point;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    33
import java.awt.Rectangle;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    34
import java.awt.Robot;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    35
import java.awt.event.InputEvent;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    36
import java.awt.event.MouseAdapter;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    37
import java.awt.event.MouseEvent;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    38
import javax.swing.JFrame;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    39
import javax.swing.JMenuItem;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    40
import javax.swing.JPanel;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    41
import javax.swing.JPopupMenu;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    42
import javax.swing.Popup;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    43
import javax.swing.PopupFactory;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    44
import javax.swing.SwingUtilities;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    45
import javax.swing.event.PopupMenuEvent;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    46
import javax.swing.event.PopupMenuListener;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    47
import javax.swing.plaf.basic.BasicPopupMenuUI;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    48
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    49
public class PopupMenuTest {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    50
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    51
    private JPopupMenu jpopup;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    52
    private static volatile boolean isLightWeight;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    53
    private static JFrame frame;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    54
    private static Robot robot;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    55
    private static JPanel panel;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    56
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    57
    public static void main(String s[]) throws Exception {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    58
        PopupMenuTest obj = new PopupMenuTest();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    59
        obj.createUI();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    60
        robot = new Robot();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    61
        robot.waitForIdle();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    62
        robot.delay(1000);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    63
        obj.exectuteTest();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    64
        obj.dispose();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    65
        if (isLightWeight) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    66
            throw new RuntimeException("Test Failed");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    67
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    68
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    69
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    70
    private void createUI() throws Exception {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    71
        SwingUtilities.invokeAndWait(() -> {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    72
            frame = new JFrame("Popup Menu");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    73
            jpopup = new JPopupMenu();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    74
            jpopup.setUI(new PopMenuUIExt());
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    75
            JMenuItem item = new JMenuItem("Menu Item1");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    76
            jpopup.add(item);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    77
            item = new JMenuItem("Menu Item2");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    78
            jpopup.setLabel("Justification");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    79
            jpopup.add(item);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    80
            jpopup.setLabel("Justification");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    81
            jpopup.addPopupMenuListener(new PopupListener());
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    82
            panel = new JPanel();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    83
            panel.addMouseListener(new MousePopupListener());
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    84
            frame.setContentPane(panel);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    85
            frame.setSize(300, 300);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    86
            frame.setLocationRelativeTo(null);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    87
            frame.setVisible(true);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    88
        });
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    89
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    90
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    91
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    92
    private void dispose() throws Exception {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    93
        SwingUtilities.invokeAndWait(() -> {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    94
            frame.dispose();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    95
        });
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    96
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    97
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    98
    private void exectuteTest() {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
    99
        Point p = frame.getLocationOnScreen();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   100
        Rectangle rect = frame.getBounds();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   101
        robot.mouseMove(p.x + rect.width / 2, p.y + rect.height / 2);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   102
        robot.mousePress(InputEvent.BUTTON3_DOWN_MASK);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   103
        robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   104
        robot.delay(1000);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   105
        robot.mouseMove(p.x + rect.width / 2 - 10, p.y + rect.height / 2 - 10);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   106
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   107
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   108
        robot.delay(1000);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   109
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   110
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   111
    class MousePopupListener extends MouseAdapter {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   112
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   113
        @Override
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   114
        public void mousePressed(MouseEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   115
            showPopup(e);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   116
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   117
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   118
        @Override
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   119
        public void mouseClicked(MouseEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   120
            showPopup(e);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   121
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   122
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   123
        @Override
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   124
        public void mouseReleased(MouseEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   125
            showPopup(e);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   126
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   127
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   128
        private void showPopup(MouseEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   129
            jpopup.show(panel, e.getX(), e.getY());
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   130
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   131
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   132
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   133
    class PopupListener implements PopupMenuListener {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   134
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   135
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   136
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   137
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   138
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   139
            Popup popup = ((PopMenuUIExt) jpopup.getUI()).getPopup();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   140
            if (popup != null) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   141
                isLightWeight = !popup.getClass().toString().
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   142
                        contains("HeavyWeightPopup");
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   143
            }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   144
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   145
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   146
        public void popupMenuCanceled(PopupMenuEvent e) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   147
        }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   148
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   149
}
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   150
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   151
class PopMenuUIExt extends BasicPopupMenuUI {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   152
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   153
    private Popup popup;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   154
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   155
    @Override
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   156
    public Popup getPopup(JPopupMenu popup, int x, int y) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   157
        PopupFactory.setSharedInstance(new PopupFactory() {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   158
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   159
            @Override
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   160
            public Popup getPopup(Component owner, Component contents,
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   161
                    int x, int y) {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   162
                return super.getPopup(popup, popup x, y, true);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   163
            }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   164
        });
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   165
        PopupFactory factory = PopupFactory.getSharedInstance();
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   166
        popup = factory.getPopup(popup, popup, x, y);
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   167
        return popup;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   168
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   169
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   170
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   171
    public Popup getPopup() {
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   172
        return popup;
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   173
    }
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   174
}
d446b5342c35 8147521: [macosx] Internal API Usage: setPopupType used to force creation of heavyweight popup
rchamyal
parents:
diff changeset
   175