test/javax/swing/Action/8133039/bug8133039.java

Print this page




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.Robot;
  25 import java.awt.event.ActionEvent;
  26 import java.awt.event.KeyEvent;
  27 import javax.swing.AbstractAction;
  28 import javax.swing.Action;
  29 import javax.swing.JComboBox;
  30 import javax.swing.JFrame;
  31 import javax.swing.JLabel;
  32 import javax.swing.KeyStroke;
  33 import javax.swing.SwingUtilities;
  34 import sun.swing.UIAction;
  35 
  36 /**
  37  * @test
  38  * @bug 8133039
  39  * @summary Provide public API to sun.swing.UIAction#isEnabled(Object)

  40  * @author Alexander Scherbatiy
  41  */
  42 public class bug8133039 {
  43 
  44     private static volatile int ACTION_PERFORMED_CALLS = 0;
  45     private static volatile int ACTION_ACCEPTED_CALLS = 0;
  46 
  47     public static void main(String[] args) throws Exception {
  48         testActionNotification();
  49         testPopupAction();
  50     }
  51 
  52     private static void testActionNotification() {
  53 
  54         KeyEvent keyEvent = new KeyEvent(new JLabel("Test"), 0, 0, 0, 0, 'A');
  55         SenderObject rejectedSenderObject = new SenderObject();
  56         SwingUtilities.notifyAction(new TestAction(false), null, keyEvent,
  57                 rejectedSenderObject, 0);
  58 
  59         if (rejectedSenderObject.accepted) {




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.awt.Robot;
  25 import java.awt.event.ActionEvent;
  26 import java.awt.event.KeyEvent;
  27 import javax.swing.AbstractAction;
  28 import javax.swing.Action;
  29 import javax.swing.JComboBox;
  30 import javax.swing.JFrame;
  31 import javax.swing.JLabel;
  32 import javax.swing.KeyStroke;
  33 import javax.swing.SwingUtilities;
  34 import sun.swing.UIAction;
  35 
  36 /**
  37  * @test
  38  * @bug 8133039
  39  * @summary Provide public API to sun.swing.UIAction#isEnabled(Object)
  40  * @modules java.desktop/sun.swing
  41  * @author Alexander Scherbatiy
  42  */
  43 public class bug8133039 {
  44 
  45     private static volatile int ACTION_PERFORMED_CALLS = 0;
  46     private static volatile int ACTION_ACCEPTED_CALLS = 0;
  47 
  48     public static void main(String[] args) throws Exception {
  49         testActionNotification();
  50         testPopupAction();
  51     }
  52 
  53     private static void testActionNotification() {
  54 
  55         KeyEvent keyEvent = new KeyEvent(new JLabel("Test"), 0, 0, 0, 0, 'A');
  56         SenderObject rejectedSenderObject = new SenderObject();
  57         SwingUtilities.notifyAction(new TestAction(false), null, keyEvent,
  58                 rejectedSenderObject, 0);
  59 
  60         if (rejectedSenderObject.accepted) {