Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Component;

import java.awt.Window;

import java.lang.reflect.Method;

import javax.swing.SwingUtilities;

public class Main {
    public static void setWindowOpacity(Component c, float opacity) {
        setWindowOpacity(SwingUtilities.getWindowAncestor(c), opacity);
    }

    public static void setWindowOpacity(Window window, float opacity) {
        try {
            Class clazz = Class.forName("com.sun.awt.AWTUtilities");
            Method opacityMethod = clazz.getDeclaredMethod("setWindowOpacity", Window.class, float.class);
            opacityMethod.invoke(null, window, opacity);
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    }
}