changeset 14244:4ca4f2c8d975

6191390: Action Event triggered by list does not reflect the modifiers properly on win32 Reviewed-by: serb, psadhukhan
author arapte
date Tue, 12 Apr 2016 14:40:58 +0530
parents 2ad92ad4e9a9
children b4e29994d167 4667ba19132d
files src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java src/java.desktop/windows/native/libawt/windows/awt_Button.cpp src/java.desktop/windows/native/libawt/windows/awt_Component.cpp src/java.desktop/windows/native/libawt/windows/awt_Component.h src/java.desktop/windows/native/libawt/windows/awt_List.cpp src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp test/java/awt/Button/ActionEventTest/ActionEventTest.java test/java/awt/List/ActionEventTest/ActionEventTest.java test/java/awt/MenuBar/ActionEventTest/ActionEventTest.java test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java
diffstat 12 files changed, 478 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java	Tue Apr 12 14:40:58 2016 +0530
@@ -1087,7 +1087,7 @@
                       }
                   } else {
                       //Invoke action event
-                      item.action(mouseEvent.getWhen());
+                      item.action(mouseEvent.getWhen(), mouseEvent.getModifiers());
                       ungrabInput();
                   }
               } else {
@@ -1200,7 +1200,7 @@
               if (citem instanceof XMenuPeer) {
                   cwnd.selectItem(citem, true);
               } else if (citem != null) {
-                  citem.action(event.getWhen());
+                  citem.action(event.getWhen(), event.getModifiers());
                   ungrabInput();
               }
               break;
--- a/src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java	Tue Apr 12 14:40:58 2016 +0530
@@ -323,11 +323,11 @@
      * on menu item.
      * @param when the timestamp of action event
      */
-    void action(long when) {
+    void action(long when, int modifiers) {
         if (!isSeparator() && isTargetItemEnabled()) {
             XWindow.postEventStatic(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
                                                     getTargetActionCommand(), when,
-                                                    0));
+                                                    modifiers));
         }
     }
     /************************************************
--- a/src/java.desktop/windows/native/libawt/windows/awt_Button.cpp	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Button.cpp	Tue Apr 12 14:40:58 2016 +0530
@@ -187,7 +187,7 @@
 AwtButton::NotifyListeners()
 {
     DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
-               (jint)AwtComponent::GetJavaModifiers());
+               (jint)AwtComponent::GetActionModifiers());
 }
 
 MsgRouting
--- a/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp	Tue Apr 12 14:40:58 2016 +0530
@@ -60,6 +60,7 @@
 #include <java_awt_Insets.h>
 #include <sun_awt_windows_WPanelPeer.h>
 #include <java_awt_event_InputEvent.h>
+#include <java_awt_event_ActionEvent.h>
 #include <java_awt_event_InputMethodEvent.h>
 #include <sun_awt_windows_WInputMethod.h>
 #include <java_awt_event_MouseEvent.h>
@@ -2587,6 +2588,27 @@
     return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
 }
 
+/* Returns Java ActionEvent modifieres.
+ * When creating ActionEvent, modifiers provided by ActionEvent
+ * class should be set.
+ */
+jint
+AwtComponent::GetActionModifiers()
+{
+    jint modifiers = GetJavaModifiers();
+
+    if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
+        modifiers |= java_awt_event_ActionEvent_CTRL_MASK;
+    }
+    if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
+        modifiers |= java_awt_event_ActionEvent_SHIFT_MASK;
+    }
+    if (modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) {
+        modifiers |= java_awt_event_ActionEvent_ALT_MASK;
+    }
+    return modifiers;
+}
+
 /* Returns Java extended InputEvent modifieres.
  * Since ::GetKeyState returns current state and Java modifiers represent
  * state before event, modifier on changed key are inverted.
--- a/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.h	Tue Apr 12 14:40:58 2016 +0530
@@ -438,6 +438,7 @@
     static void InitDynamicKeyMapTable();
     static void BuildDynamicKeyMapTable();
     static jint GetJavaModifiers();
+    static jint GetActionModifiers();
     static jint GetButton(int mouseButton);
     static UINT GetButtonMK(int mouseButton);
     static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers, UINT character, BOOL isDeadKey);
--- a/src/java.desktop/windows/native/libawt/windows/awt_List.cpp	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_List.cpp	Tue Apr 12 14:40:58 2016 +0530
@@ -536,7 +536,7 @@
             else if (notifyCode == LBN_DBLCLK) {
                 DoCallback("handleAction", "(IJI)V", nCurrentSelection,
                            ::JVM_CurrentTimeMillis(NULL, 0),
-                           (jint)AwtComponent::GetJavaModifiers());
+                           (jint)AwtComponent::GetActionModifiers());
             }
         }
     }
--- a/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp	Tue Apr 12 14:40:58 2016 +0530
@@ -667,7 +667,7 @@
         DoCallback("handleAction", "(Z)V", ((nState & MF_CHECKED) == 0));
     } else {
         DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
-                   (jint)AwtComponent::GetJavaModifiers());
+                   (jint)AwtComponent::GetActionModifiers());
     }
 }
 
--- a/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Mon Apr 11 21:41:43 2016 -0500
+++ b/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp	Tue Apr 12 14:40:58 2016 +0530
@@ -409,7 +409,7 @@
         MSG msg;
         AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
         SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
-                        AwtComponent::GetJavaModifiers(), &msg);
+                        AwtComponent::GetActionModifiers(), &msg);
     }
     return mrConsume;
 }
@@ -425,7 +425,7 @@
         MSG msg;
         AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
         SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
-                        AwtComponent::GetJavaModifiers(), &msg);
+                        AwtComponent::GetActionModifiers(), &msg);
     }
     lastKeySelectTime = now;
 
@@ -442,7 +442,7 @@
         MSG msg;
         AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
         SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
-                        AwtComponent::GetJavaModifiers(), &msg);
+                        AwtComponent::GetActionModifiers(), &msg);
     }
     return mrConsume;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Button/ActionEventTest/ActionEventTest.java	Tue Apr 12 14:40:58 2016 +0530
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main/manual ActionEventTest
+ */
+
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Button;
+import java.awt.TextArea;
+import java.awt.Robot;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+public class ActionEventTest extends Frame {
+    Button button;
+    Robot robot;
+    TextArea instructions;
+    public static boolean isProgInterruption = false;
+    static Thread mainThread = null;
+    static int sleepTime = 300000;
+
+    public ActionEventTest() {
+        try {
+            robot = new Robot();
+        } catch(AWTException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+
+        button = new Button("ClickMe");
+        button.setEnabled(true);
+
+        instructions = new TextArea(10, 50);
+        instructions.setText(
+        " This is a manual test\n" +
+        " Keep the Alt, Shift & Ctrl Keys pressed &\n" +
+        " Click 'ClickMe' button with left mouse button\n" +
+        " Test exits automatically after mouse click.");
+
+        add(button);
+        add(instructions);
+        setSize(400,400);
+        setLayout(new FlowLayout());
+        pack();
+        setVisible(true);
+        robot.waitForIdle();
+
+        button.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                int md = ae.getModifiers();
+                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+                        | ActionEvent.SHIFT_MASK;
+
+                isProgInterruption = true;
+                mainThread.interrupt();
+                if ((md & expectedMask) != expectedMask) {
+                    throw new RuntimeException("Action Event modifiers"
+                        + " are not set correctly.");
+                }
+            }
+        });
+    }
+
+    public static void main(String args[]) throws Exception {
+        mainThread = Thread.currentThread();
+        ActionEventTest test = new ActionEventTest();
+        try {
+            mainThread.sleep(sleepTime);
+        } catch (InterruptedException e) {
+            if (!isProgInterruption) {
+                throw e;
+            }
+        }
+        test.dispose();
+        if (!isProgInterruption) {
+            throw new RuntimeException("Timed out after " + sleepTime / 1000
+                    + " seconds");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/List/ActionEventTest/ActionEventTest.java	Tue Apr 12 14:40:58 2016 +0530
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main ActionEventTest
+ */
+
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.List;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+public class ActionEventTest extends Frame {
+    List list;
+    Robot robot;
+
+    public ActionEventTest() {
+        try {
+            robot = new Robot();
+        } catch(AWTException e) {
+            throw new RuntimeException(e.getMessage());
+        }
+
+        list = new List(1, false);
+        list.add("0");
+        add(list);
+        setSize(400,400);
+        setLayout(new FlowLayout());
+        pack();
+        setVisible(true);
+        robot.waitForIdle();
+    }
+
+    void performTest() {
+        list.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                int md = ae.getModifiers();
+                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+                        | ActionEvent.SHIFT_MASK;
+
+                if ((md & expectedMask) != expectedMask) {
+
+                    robot.keyRelease(KeyEvent.VK_ALT);
+                    robot.keyRelease(KeyEvent.VK_SHIFT);
+                    robot.keyRelease(KeyEvent.VK_CONTROL);
+                    dispose();
+                    throw new RuntimeException("Action Event modifiers are not"
+                        + " set correctly.");
+                }
+            }
+        });
+
+        list.select(0);
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_CONTROL);
+        // Press Enter on list item, to generate action event.
+        robot.keyPress(KeyEvent.VK_ENTER);
+        robot.keyRelease(KeyEvent.VK_ENTER);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
+        robot.waitForIdle();
+    }
+
+    public static void main(String args[]) {
+       ActionEventTest test = new ActionEventTest();
+       test.performTest();
+       test.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/MenuBar/ActionEventTest/ActionEventTest.java	Tue Apr 12 14:40:58 2016 +0530
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main/manual ActionEventTest
+ */
+
+import java.awt.Frame;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public final class ActionEventTest extends Frame {
+
+    MenuBar menuBar;
+    TextArea instructions;
+    public static boolean isProgInterruption = false;
+    static Thread mainThread = null;
+    static int sleepTime = 300000;
+
+    public ActionEventTest() {
+        menuBar = new MenuBar();
+        Menu menu = new Menu("Menu1");
+        MenuItem menuItem = new MenuItem("MenuItem");
+
+        menuItem.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                System.out.println("actionPerformed");
+                int md = ae.getModifiers();
+                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+                        | ActionEvent.SHIFT_MASK;
+
+                isProgInterruption = true;
+                mainThread.interrupt();
+                if ((md & expectedMask) != expectedMask) {
+                    throw new RuntimeException("Action Event modifiers are not"
+                        + " set correctly.");
+                }
+            }
+        });
+        menu.add(menuItem);
+        menuBar.add(menu);
+        setMenuBar(menuBar);
+
+        instructions = new TextArea(10, 50);
+        instructions.setText(
+        " This is a manual test\n" +
+        " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
+        " Click 'Menu1' Menu from the Menu Bar\n" +
+        " It will show 'MenuItem'\n" +
+        " Left mouse Click the 'MenuItem'\n" +
+        " Test exits automatically after mouse click.");
+        add(instructions);
+
+        setSize(400, 400);
+        setVisible(true);
+        validate();
+    }
+
+
+    public static void main(final String[] args) throws Exception {
+        mainThread = Thread.currentThread();
+        ActionEventTest test = new ActionEventTest();
+        try {
+            mainThread.sleep(sleepTime);
+        } catch (InterruptedException e) {
+            if (!isProgInterruption) {
+                throw e;
+            }
+        }
+        test.dispose();
+        if (!isProgInterruption) {
+            throw new RuntimeException("Timed out after " + sleepTime / 1000
+                    + " seconds");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java	Tue Apr 12 14:40:58 2016 +0530
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @library ../../../../lib/testlibrary ../
+ * @build ExtendedRobot SystemTrayIconHelper
+ */
+
+import java.awt.Image;
+import java.awt.TrayIcon;
+import java.awt.SystemTray;
+import java.awt.Robot;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+
+public class ActionEventTest {
+
+    Image image;
+    TrayIcon icon;
+    Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        if (!SystemTray.isSupported()) {
+            System.out.println("SystemTray not supported on the platform." +
+                " Marking the test passed.");
+        } else {
+            if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
+                System.err.println(
+                    "Test can fail on Windows platform\n"+
+                    "On Windows 7, by default icon hides behind icon pool\n" +
+                    "Due to which test might fail\n" +
+                    "Set \"Right mouse click\" -> " +
+                    "\"Customize notification icons\" -> \"Always show " +
+                    "all icons and notifications on the taskbar\" true " +
+                    "to avoid this problem.\nOR change behavior only for " +
+                    "Java SE tray icon and rerun test.");
+            }
+
+            ActionEventTest test = new ActionEventTest();
+            test.doTest();
+            test.clear();
+        }
+    }
+
+    public ActionEventTest() throws Exception {
+        robot = new Robot();
+        EventQueue.invokeAndWait(this::initializeGUI);
+    }
+
+    private void initializeGUI() {
+
+        icon = new TrayIcon(
+            new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "ti");
+        icon.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent ae) {
+                int md = ae.getModifiers();
+                int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+                        | ActionEvent.SHIFT_MASK;
+
+                if ((md & expectedMask) != expectedMask) {
+                    clear();
+                    throw new RuntimeException("Action Event modifiers are not"
+                        + " set correctly.");
+                }
+            }
+        });
+
+        try {
+            SystemTray.getSystemTray().add(icon);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public void clear() {
+        SystemTray.getSystemTray().remove(icon);
+    }
+
+    void doTest() throws Exception {
+        robot.keyPress(KeyEvent.VK_ALT);
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_CONTROL);
+
+        Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
+        if (iconPosition == null) {
+            throw new RuntimeException("Unable to find the icon location!");
+        }
+
+        robot.mouseMove(iconPosition.x, iconPosition.y);
+        robot.waitForIdle();
+
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        robot.delay(100);
+        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+        robot.delay(100);
+        robot.waitForIdle();
+        robot.keyRelease(KeyEvent.VK_ALT);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
+    }
+}