Java GraphicsDevice check window translucency support

Description

Java GraphicsDevice check window translucency support

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

public class Main {
  public static void main(String[] args) {
    GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();

    GraphicsDevice graphicsDevice = graphicsEnv.getDefaultScreenDevice();

    // Print the translucency supported by the platform
    boolean isSupported = graphicsDevice.isWindowTranslucencySupported(
        WindowTranslucency.PERPIXEL_TRANSPARENT);
    System.out.println("PERPIXEL_TRANSPARENT supported: " + isSupported);

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

    isSupported = graphicsDevice.isWindowTranslucencySupported(
        WindowTranslucency.PERPIXEL_TRANSLUCENT);
    System.out.println("PERPIXEL_TRANSLUCENT supported: " + isSupported);
  }//from  ww w  .  ja  v  a2 s  .  c  o m
}



PreviousNext

Related