< prev index next >

test/jdk/java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java

Print this page




  62             public void actionPerformed(ActionEvent e) {
  63                 b1.setEnabled(false);
  64                 b2.setEnabled(false);
  65             }
  66         });
  67     }
  68 
  69     public void start() {
  70         Util.showWindowWait(frame);
  71 
  72         // Request focus on b1.
  73         if (!Util.focusComponent(b1, 2000)) {
  74             throw new TestErrorException("couldn't focus " + b1);
  75         }
  76 
  77         // Activate b1.
  78         robot.keyPress(KeyEvent.VK_SPACE);
  79         robot.delay(50);
  80         robot.keyRelease(KeyEvent.VK_SPACE);
  81         Util.waitForIdle(robot);
  82         robot.delay(2000);
  83 
  84         // Check that focus has been transfered to b0.
  85         if (!b0.hasFocus()) {
  86             throw new TestFailedException("focus wasn't auto-transfered properly!");
  87         }
  88         System.out.println("Test passed.");
  89     }
  90 }
  91 
  92 /**
  93  * Thrown when the behavior being verified is found wrong.
  94  */
  95 class TestFailedException extends RuntimeException {
  96     TestFailedException(String msg) {
  97         super("Test failed: " + msg);
  98     }
  99 }
 100 
 101 /**
 102  * Thrown when an error not related to the behavior being verified is encountered.


  62             public void actionPerformed(ActionEvent e) {
  63                 b1.setEnabled(false);
  64                 b2.setEnabled(false);
  65             }
  66         });
  67     }
  68 
  69     public void start() {
  70         Util.showWindowWait(frame);
  71 
  72         // Request focus on b1.
  73         if (!Util.focusComponent(b1, 2000)) {
  74             throw new TestErrorException("couldn't focus " + b1);
  75         }
  76 
  77         // Activate b1.
  78         robot.keyPress(KeyEvent.VK_SPACE);
  79         robot.delay(50);
  80         robot.keyRelease(KeyEvent.VK_SPACE);
  81         Util.waitForIdle(robot);

  82 
  83         // Check that focus has been transfered to b0.
  84         if (!b0.hasFocus()) {
  85             throw new TestFailedException("focus wasn't auto-transfered properly!");
  86         }
  87         System.out.println("Test passed.");
  88     }
  89 }
  90 
  91 /**
  92  * Thrown when the behavior being verified is found wrong.
  93  */
  94 class TestFailedException extends RuntimeException {
  95     TestFailedException(String msg) {
  96         super("Test failed: " + msg);
  97     }
  98 }
  99 
 100 /**
 101  * Thrown when an error not related to the behavior being verified is encountered.
< prev index next >