< prev index next >

test/java/awt/TrayIcon/ActionEventMask/ActionEventMask.java

Print this page




  49     boolean listenersInvoked = false;
  50     Object actionLock = new Object();
  51     Object listenersLock = new Object();
  52     static boolean isMacOS = false;
  53     static final int clickDelay = 50;
  54 
  55     ActionListener[] listeners;
  56     boolean[] listenerStatus;
  57 
  58     Object lLock = new Object();
  59     boolean doTest, listenerAdded;
  60     Button b1;
  61 
  62     public static void main(String[] args) throws Exception {
  63         if (! SystemTray.isSupported()) {
  64             System.out.println("SystemTray not supported on the platform under test. " +
  65                                "Marking the test passed");
  66         } else {
  67             if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
  68                 isMacOS = true;




  69             }
  70             new ActionEventMask().doTest();
  71         }
  72     }
  73 
  74     public ActionEventMask() throws Exception {
  75         EventQueue.invokeAndWait(this::initializeGUI);
  76     }
  77 
  78     void initializeGUI() {
  79         SystemTray tray = SystemTray.getSystemTray();
  80         icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
  81 
  82         Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
  83             if (doTest) {
  84                 System.out.println("ActionListener AWTEventListener");
  85                 if (! icon.equals(event.getSource())) {
  86                     throw new RuntimeException("FAIL: ActionEvent not triggered for icon");
  87                 }
  88                 actionPerformed = true;




  49     boolean listenersInvoked = false;
  50     Object actionLock = new Object();
  51     Object listenersLock = new Object();
  52     static boolean isMacOS = false;
  53     static final int clickDelay = 50;
  54 
  55     ActionListener[] listeners;
  56     boolean[] listenerStatus;
  57 
  58     Object lLock = new Object();
  59     boolean doTest, listenerAdded;
  60     Button b1;
  61 
  62     public static void main(String[] args) throws Exception {
  63         if (! SystemTray.isSupported()) {
  64             System.out.println("SystemTray not supported on the platform under test. " +
  65                                "Marking the test passed");
  66         } else {
  67             if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
  68                 isMacOS = true;
  69             } else if (SystemTrayIconHelper.isOel7()) {
  70                 System.out.println("OEL 7 doesn't support double click in " +
  71                         "systray. Skipped");
  72                 return;
  73             }
  74             new ActionEventMask().doTest();
  75         }
  76     }
  77 
  78     public ActionEventMask() throws Exception {
  79         EventQueue.invokeAndWait(this::initializeGUI);
  80     }
  81 
  82     void initializeGUI() {
  83         SystemTray tray = SystemTray.getSystemTray();
  84         icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "Sample Icon");
  85 
  86         Toolkit.getDefaultToolkit().addAWTEventListener(event -> {
  87             if (doTest) {
  88                 System.out.println("ActionListener AWTEventListener");
  89                 if (! icon.equals(event.getSource())) {
  90                     throw new RuntimeException("FAIL: ActionEvent not triggered for icon");
  91                 }
  92                 actionPerformed = true;


< prev index next >