View RSS Feed

DuvanSlabbert

Setting JWindow or JFrame Opacity

Rate this Entry
by , 10-17-2011 at 09:37 PM (3238 Views)
Ever wanted to try and set the transparency level of some JWindow's or JFrames? Here is another snippet of code to keep close by that might come in handy.

Java Code:
try {
	Class<?> awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
	Method method = awtUtilitiesClass.getMethod("setWindowOpacity", Window.class, float.class);	
		
	method.invoke(null, /*JFrame or JWindow here*/, /*The opacity level in float value from 0.0 to 1*/);
} catch (Exception exc) {
	exc.printStackTrace();
}

Submit "Setting JWindow or JFrame Opacity" to Facebook Submit "Setting JWindow or JFrame Opacity" to Digg Submit "Setting JWindow or JFrame Opacity" to del.icio.us Submit "Setting JWindow or JFrame Opacity" to StumbleUpon Submit "Setting JWindow or JFrame Opacity" to Google

Updated 10-19-2011 at 09:41 AM by DuvanSlabbert

Categories
AWT and Swing

Comments