Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hideSplashScreen() opacity issue #4

Open
GitUser73937 opened this issue Apr 25, 2014 · 1 comment
Open

hideSplashScreen() opacity issue #4

GitUser73937 opened this issue Apr 25, 2014 · 1 comment

Comments

@GitUser73937
Copy link

When running in eclipse in linux I get the below error :

Exception in thread "main" java.lang.UnsupportedOperationException: TRANSLUCENT translucency is not supported.
    at java.awt.Window.setOpacity(Window.java:3598)
    at java.awt.Frame.setOpacity(Frame.java:962)
    at edu.drexel.psal.anonymouth.gooie.SplashScreen.hideSplashScreen(SplashScreen.java:154)
    at edu.drexel.psal.anonymouth.gooie.ThePresident.<init>(ThePresident.java:164)
    at edu.drexel.psal.anonymouth.gooie.ThePresident.main(ThePresident.java:70)

I was able to rectify this by removing line 154 in SplashScreen.java

@krouskop
Copy link

I encountered the same error and also got around it by commenting out all but splashScreen.setVisible(false); in hideSplashScreen().

FWIW, the JavaSE tutorial has this recommendation on Determining a Platform's Capabilities in this regard.

Not all platforms support all of these capabilities. An UnsupportedOperationException exception is thrown when code attempts to invoke the setShape or setOpacity methods on a platform that does not support these capabilities. Therefore, it is best practice to first check that the platform supports the capability that you want to implement. The GraphicsDevice class provides the
isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) method that you can use for this purpose. You pass one of three enum values, defined in
GraphicsDevice.WindowTranslucency, to this method:
*TRANSLUCENT – The underlying platform supports windows with uniform translucency, where each pixel has the same alpha value.
*PERPIXEL_TRANSLUCENT – The underlying platform supports windows with per-pixel translucency. This capability is required to implement windows that fade away.
*PERPIXEL_TRANSPARENT – The underlying platform supports shaped windows.

The GraphicsConfiguration class also provides the
isTranslucencyCapable method to determine if PERPIXEL_TRANSLUCENT translucency is supported by the given GraphicsConfiguration object.

The following code shows how to check for all three capabilities:

import static java.awt.GraphicsDevice.WindowTranslucency.*;

// Determine what the default GraphicsDevice can support.
GraphicsEnvironment ge =
    GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();

boolean isUniformTranslucencySupported =
    gd.isWindowTranslucencySupported(TRANSLUCENT);
boolean isPerPixelTranslucencySupported =
    gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
boolean isShapedWindowSupported =
    gd.isWindowTranslucencySupported(PERPIXEL_TRANSPARENT);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants