本文整理汇总了Java中com.sun.awt.AWTUtilities.isTranslucencySupported方法的典型用法代码示例。如果您正苦于以下问题:Java AWTUtilities.isTranslucencySupported方法的具体用法?Java AWTUtilities.isTranslucencySupported怎么用?Java AWTUtilities.isTranslucencySupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.awt.AWTUtilities
的用法示例。
在下文中一共展示了AWTUtilities.isTranslucencySupported方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IntroScreen
import com.sun.awt.AWTUtilities; //导入方法依赖的package包/类
public IntroScreen(){
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds((int)(screenSize.getWidth()-640)/2,(int)(screenSize.getHeight()-480)/2,640,480);
setUndecorated(true);
setAlwaysOnTop(true);
try{if(AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT))
AWTUtilities.setWindowOpaque(this, false);
else if(AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT))
AWTUtilities.setWindowOpacity(this, 0.7f);}
catch(Exception e){e.printStackTrace();}
}
示例2: main
import com.sun.awt.AWTUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GraphicsConfiguration gc = getGC();
if (!AWTUtilities.isTranslucencySupported(
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|| gc == null) {
return;
}
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Robot robot = new Robot();
final JFrame testFrame = new JFrame(gc);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame backgroundFrame = new JFrame("Background frame");
backgroundFrame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBackground(Color.RED);
backgroundFrame.add(panel);
backgroundFrame.setSize(200, 200);
backgroundFrame.setVisible(true);
testFrame.setUndecorated(true);
JPanel p = new JPanel();
p.setOpaque(false);
testFrame.add(p);
AWTUtilities.setWindowOpaque(testFrame, false);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setSize(400, 400);
testFrame.setLocation(0, 0);
testFrame.setVisible(true);
}
});
toolkit.realSync();
//robot.getPixelColor() didn't work right for some reason
BufferedImage capture = robot.createScreenCapture(new Rectangle(100, 100));
int redRGB = Color.RED.getRGB();
if (redRGB != capture.getRGB(10, 10)) {
throw new RuntimeException("Transparent frame is not transparent!");
}
}
示例3: main
import com.sun.awt.AWTUtilities; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
GraphicsConfiguration gc = getGC();
if (!AWTUtilities.isTranslucencySupported(
AWTUtilities.Translucency.PERPIXEL_TRANSLUCENT)
|| gc == null) {
return;
}
Robot robot = new Robot();
final JFrame testFrame = new JFrame(gc);
SwingUtilities.invokeAndWait(() -> {
JFrame backgroundFrame = new JFrame("Background frame");
backgroundFrame.setUndecorated(true);
JPanel panel = new JPanel();
panel.setBackground(Color.RED);
backgroundFrame.add(panel);
backgroundFrame.setBounds(LOC, LOC, SIZE, SIZE);
backgroundFrame.setVisible(true);
testFrame.setUndecorated(true);
JPanel p = new JPanel();
p.setOpaque(false);
testFrame.add(p);
AWTUtilities.setWindowOpaque(testFrame, false);
testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
testFrame.setBounds(LOC, LOC, SIZE, SIZE);
testFrame.setVisible(true);
});
robot.waitForIdle();
Thread.sleep(1500);
//robot.getPixelColor() didn't work right for some reason
BufferedImage capture =
robot.createScreenCapture(new Rectangle(LOC, LOC, SIZE, SIZE));
int redRGB = Color.RED.getRGB();
if (redRGB != capture.getRGB(SIZE/2, SIZE/2)) {
throw new RuntimeException("Transparent frame is not transparent!");
}
}