Checking for the Translucency support on a Platform - Java 2D Graphics

Java examples for 2D Graphics:GraphicsDevice

Description

Checking for the Translucency support on a Platform

Demo Code

import static java.awt.GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSLUCENT;
import static java.awt.GraphicsDevice.WindowTranslucency.PERPIXEL_TRANSPARENT;
import static java.awt.GraphicsDevice.WindowTranslucency.TRANSLUCENT;

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

public class Main {
  public static void main(String[] args) {
    GraphicsEnvironment graphicsEnv = GraphicsEnvironment
        .getLocalGraphicsEnvironment();/*from  ww w  . ja va  2 s  . c  o  m*/

    GraphicsDevice graphicsDevice = graphicsEnv.getDefaultScreenDevice();

    boolean isSupported = graphicsDevice
        .isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);
    System.out.println("PERPIXEL_TRANSPARENT supported: " + isSupported);

    isSupported = graphicsDevice.isWindowTranslucencySupported(TRANSLUCENT);
    System.out.println("TRANSLUCENT supported: " + isSupported);

    isSupported = graphicsDevice
        .isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
    System.out.println("PERPIXEL_TRANSLUCENT supported: " + isSupported);
  }
}

Related Tutorials