Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?

前端 未结 5 1459
情歌与酒
情歌与酒 2020-12-02 00:25

Here\'s the example.

If you build and run TranslucentWindow in let\'s say, NetBeans IDE 7.0, which supports jdk7, you\'ll get the following exception:<

5条回答
  •  感情败类
    2020-12-02 00:54

    Right from the JavaDocs for java.awt.frame.setOpacity() in JDK7:

    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.

    The behavior that you are seeing is documented and is expected behavior.

提交回复
热议问题