Java Graphics Settings getTransparentGraphicsConfiguration()

Here you can find the source of getTransparentGraphicsConfiguration()

Description

get Transparent Graphics Configuration

License

Open Source License

Declaration

static GraphicsConfiguration getTransparentGraphicsConfiguration() 

Method Source Code

//package com.java2s;

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

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    static GraphicsConfiguration getTransparentGraphicsConfiguration() {
        try {//from w w  w.  j  a  v  a2  s  . c o m
            Class<?> awtUtilitiesType = Class.forName("com.sun.awt.AWTUtilities");
            Method isTC = awtUtilitiesType.getMethod("isTranslucencyCapable",
                    new Class[] { GraphicsConfiguration.class });

            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] devices = env.getScreenDevices();
            GraphicsConfiguration translucencyCapableGC = null;

            for (int i = 0; (i < devices.length) && (translucencyCapableGC == null); ++i) {
                GraphicsConfiguration[] configs = devices[i].getConfigurations();
                for (int j = 0; (j < configs.length) && (translucencyCapableGC == null); ++j) {
                    Boolean res = (Boolean) isTC.invoke(null, new Object[] { configs[j] });
                    if (res.booleanValue()) {
                        translucencyCapableGC = configs[j];
                        System.out.println("FOUND translucency capable GC: " + configs[j]);
                    }
                }
            }
            return translucencyCapableGC;
        } catch (ClassNotFoundException cnfe) {
            return null;
        } catch (NoSuchMethodException nsme) {
            return null;
        } catch (IllegalAccessException iae) {
            return null;
        } catch (InvocationTargetException ite) {
        }
        return null;
    }
}

Related

  1. getMaxWindowBounds(final GraphicsConfiguration gc, final boolean applyScreenInsets)
  2. getRenderingHints(final Graphics2D g2d, final Map hintsToSave, Map savedHints)
  3. getRenderingHints(Graphics2D g2d, Map hintsToSave, RenderingHints savedHints)
  4. getRenderingHints(Graphics2D g2d, RenderingHints hintsToSave, RenderingHints savedHints)
  5. getSecondWindowConfiguration()
  6. gradientFillShape(Graphics2D g, Color startColor, Color endColor, Shape shape)
  7. gradientPaint(Graphics2D g2d, Point2D startPosition, Color startColor, Point2D endPosition, Color endColor, int sx, int sy, int ex, int ey)
  8. setClip(Graphics g, Rectangle clipBounds)
  9. setRenderingHints(Graphics2D g)