2013-02-27 66 views
-3

爲什麼這個聲明的Java(NetBeans IDE中7.2.1)爲什麼這個錯誤在java中發生

com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.3f); 

做出以下錯誤:

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated 
    at java.awt.Frame.setOpacity(Frame.java:960) 
+1

嗨,歡迎來到SO!爲了讓人們幫助您解決問題,請考慮提供更多信息。你的問題太籠統,太模糊。 – 2013-02-27 14:52:03

回答

3

從Java文檔

The opacity value is in the range [0..1]. Note that setting the opacity level of 0 may or may not disable the mouse event handling on this window. This is a platform-dependent behavior.

The following conditions must be met in order to set the opacity value less than 1.0f:

  • The TRANSLUCENT translucency must be supported by the underlying system
  • The window must be undecorated (see setUndecorated(boolean) and > Dialog.setUndecorated(boolean))
  • The window must not be in full-screen mode (see > GraphicsDevice.setFullScreenWindow(Window))

If the requested opacity value is less than 1.0f, and any of the above conditions are not met, the window opacity will not change, and the IllegalComponentStateException will be thrown.

你顯然沒有遇到其中一個條件,最喜歡的第二個

相關問題