当前位置: 首页>>代码示例>>Java>>正文


Java AWTUtilities.isTranslucencySupported方法代码示例

本文整理汇总了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();}
}
 
开发者ID:twister,项目名称:twister.github.io,代码行数:12,代码来源:IntroScreen.java

示例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!");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:44,代码来源:bug6683775.java

示例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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:bug6683775.java


注:本文中的com.sun.awt.AWTUtilities.isTranslucencySupported方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。