public static boolean reflectGraphicsEnvironmentISHeadlessInstance(Object graphicsEnvironment, boolean defaultReturnIfNoMethod) {
        try {
            Class clazz = graphicsEnvironment.getClass();
            Method isHeadlessInstanceMethod = clazz.getMethod("isHeadlessInstance", new Class[]{});
            if (isHeadlessInstanceMethod != null) {
                Object ret = isHeadlessInstanceMethod.invoke(
                        graphicsEnvironment, new Object[]{});
                if (ret instanceof Boolean)
                    return ((Boolean) ret).booleanValue();
            }
        }
        catch (Throwable t) {
            logger.log(Level.FINE,
                    "ImageCache: Java 1.4 Headless support not found.");
        }
        return defaultReturnIfNoMethod;
    }