< prev index next >

test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java

Print this page




  83             }
  84         }
  85         if (graphicsConfig == null) {
  86             System.out.println("The system does not support translucency. Consider the test passed.");
  87             return;
  88         }
  89 
  90         Robot r = new Robot();
  91         Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates
  92 
  93         SwingUtilities.invokeAndWait(new Runnable() {
  94             public void run() {
  95                 initAndShowGUI();
  96             }
  97         });
  98         r.waitForIdle();
  99 
 100         if (!paintComponentCalled) {
 101             throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
 102         }

 103 
 104         Color newColor1 = r.getPixelColor(100, 100);
 105         // unfortunately, robot.getPixelColor() doesn't work for some unknown reason
 106         // Color newColor2 = r.getPixelColor(200, 200);
 107         BufferedImage bim = r.createScreenCapture(new Rectangle(200, 200, 1, 1));
 108         Color newColor2 = new Color(bim.getRGB(0, 0));
 109 
 110         // Frame must be transparent at (100, 100) in screen coords
 111         if (!color1.equals(newColor1)) {
 112             System.err.println("color1 = " + color1);
 113             System.err.println("newColor1 = " + newColor1);
 114             throw new RuntimeException("Test FAILED: frame pixel at (0, 0) is not transparent");
 115         }
 116 
 117         // Frame must be RED at (200, 200) in screen coords
 118         if (!newColor2.equals(Color.RED)) {
 119             System.err.println("newColor2 = " + newColor2);
 120             throw new RuntimeException("Test FAILED: frame pixel at (100, 100) is not red (transparent?)");
 121         }
 122 


  83             }
  84         }
  85         if (graphicsConfig == null) {
  86             System.out.println("The system does not support translucency. Consider the test passed.");
  87             return;
  88         }
  89 
  90         Robot r = new Robot();
  91         Color color1 = r.getPixelColor(100, 100); // (0, 0) in frame coordinates
  92 
  93         SwingUtilities.invokeAndWait(new Runnable() {
  94             public void run() {
  95                 initAndShowGUI();
  96             }
  97         });
  98         r.waitForIdle();
  99 
 100         if (!paintComponentCalled) {
 101             throw new RuntimeException("Test FAILED: panel's paintComponent() method is not called");
 102         }
 103         Thread.sleep(1500);
 104 
 105         Color newColor1 = r.getPixelColor(100, 100);
 106         // unfortunately, robot.getPixelColor() doesn't work for some unknown reason
 107         // Color newColor2 = r.getPixelColor(200, 200);
 108         BufferedImage bim = r.createScreenCapture(new Rectangle(200, 200, 1, 1));
 109         Color newColor2 = new Color(bim.getRGB(0, 0));
 110 
 111         // Frame must be transparent at (100, 100) in screen coords
 112         if (!color1.equals(newColor1)) {
 113             System.err.println("color1 = " + color1);
 114             System.err.println("newColor1 = " + newColor1);
 115             throw new RuntimeException("Test FAILED: frame pixel at (0, 0) is not transparent");
 116         }
 117 
 118         // Frame must be RED at (200, 200) in screen coords
 119         if (!newColor2.equals(Color.RED)) {
 120             System.err.println("newColor2 = " + newColor2);
 121             throw new RuntimeException("Test FAILED: frame pixel at (100, 100) is not red (transparent?)");
 122         }
 123 
< prev index next >