< prev index next >

test/jdk/javax/swing/JWindow/ShapedAndTranslucentWindows/PerPixelTranslucentSwing.java

Print this page




  71 
  72         JTextField south = new JTextField("South");
  73         contentPane.add(south, BorderLayout.SOUTH);
  74 
  75         window.pack();
  76         window.setVisible(true);
  77 
  78         north.requestFocus();
  79     }
  80 
  81     @Override
  82     public void doTest() throws Exception {
  83         robot.waitForIdle(delay);
  84 
  85         // Check for background translucency
  86         Rectangle bounds = north.getBounds();
  87         Point loc = north.getLocationOnScreen();
  88 
  89         Color color = robot.getPixelColor(loc.x + bounds.width / 2, loc.y + bounds.height + 3);
  90         System.out.println(color);
  91         if (FG_COLOR.getRGB() == color.getRGB())
  92             throw new RuntimeException("Background is not translucent (" + color + ")");
  93 
  94         EventQueue.invokeAndWait(this::dispose);
  95     }
  96 }


  71 
  72         JTextField south = new JTextField("South");
  73         contentPane.add(south, BorderLayout.SOUTH);
  74 
  75         window.pack();
  76         window.setVisible(true);
  77 
  78         north.requestFocus();
  79     }
  80 
  81     @Override
  82     public void doTest() throws Exception {
  83         robot.waitForIdle(delay);
  84 
  85         // Check for background translucency
  86         Rectangle bounds = north.getBounds();
  87         Point loc = north.getLocationOnScreen();
  88 
  89         Color color = robot.getPixelColor(loc.x + bounds.width / 2, loc.y + bounds.height + 3);
  90         System.out.println(color);
  91         if (BG_COLOR.getRGB() != color.getRGB())
  92             throw new RuntimeException("Background is not translucent (" + color + ")");
  93 
  94         EventQueue.invokeAndWait(this::dispose);
  95     }
  96 }
< prev index next >