test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java

Print this page




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 7160951
  27  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  28  * @author vera.akulova@oracle.com
  29  * @run main ActionListenerCalledTwiceTest
  30  */
  31 
  32 import sun.awt.*;
  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import javax.swing.*;
  36 
  37 public class ActionListenerCalledTwiceTest {
  38     static String menuItems[] = { "Item1", "Item2", "Item3" };
  39     static KeyStroke keyStrokes[] = {
  40         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
  41         KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
  42         KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),

  43     };
  44 
  45     static volatile int listenerCallCounter = 0;
  46     public static void main(String[] args) throws Exception {
  47         if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
  48             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
  49             return;
  50         }
  51 
  52         System.setProperty("apple.laf.useScreenMenuBar", "true");
  53         SwingUtilities.invokeAndWait(new Runnable() {
  54             public void run() {
  55                 createAndShowGUI();
  56             }
  57         });
  58 
  59         SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
  60         Robot robot = new Robot();
  61         robot.setAutoDelay(100);
  62 




  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 7160951
  27  * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  28  * @author vera.akulova@oracle.com
  29  * @run main ActionListenerCalledTwiceTest
  30  */
  31 
  32 import sun.awt.*;
  33 import java.awt.*;
  34 import java.awt.event.*;
  35 import javax.swing.*;
  36 
  37 public class ActionListenerCalledTwiceTest {
  38     static String menuItems[] = { "Item1", "Item2", "Item3", "Item4" };
  39     static KeyStroke keyStrokes[] = {
  40         KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
  41         KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
  42         KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
  43         KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_MASK)
  44     };
  45 
  46     static volatile int listenerCallCounter = 0;
  47     public static void main(String[] args) throws Exception {
  48         if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
  49             System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
  50             return;
  51         }
  52 
  53         System.setProperty("apple.laf.useScreenMenuBar", "true");
  54         SwingUtilities.invokeAndWait(new Runnable() {
  55             public void run() {
  56                 createAndShowGUI();
  57             }
  58         });
  59 
  60         SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
  61         Robot robot = new Robot();
  62         robot.setAutoDelay(100);
  63