Is it possible to have a translucent windows in java 7 including a title bar?

前端 未结 2 971
天涯浪人
天涯浪人 2021-01-12 12:39

Related to this question: Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?

with jdk1.6.0_26 I seem to be able to apply tra

相关标签:
2条回答
  • 2021-01-12 13:09

    Fascinatingly, if you add

    JFrame.setDefaultLookAndFeelDecorated(true);
    

    Then it allows you to have a draggable, with title bar JFrame (it just uses the ugly java look and feel).

    ref: Pass mouse events to applications behind from a Java UI

    Now that is weird.

    Also note that you can "fake" the old behavior using per pixel transparency, see http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html

    so you can have the old behavior in both java 6 and 7, but you'd have to special case the code around it and do it one way for one, one way for the other, possibly...

    0 讨论(0)
  • 2021-01-12 13:14

    Java 7 introduced Window.setOpacity() to do what the unofficial class AWTUtilities did in Java 6.

    Unfortunately it's documented not to work with decorated windows:

    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 Frame.setUndecorated(boolean) and Dialog.setUndecorated(boolean))
    • The window must not be in full-screen mode (see GraphicsDevice.setFullScreenWindow(Window))

    (Emphasis mine)

    0 讨论(0)
提交回复
热议问题