Search code examples
javawindowtransparency

Java registering events through window


What I would like in Java is to create a transparent screen over the entire screen that does not respond to events such as mouse or keyboard. Essentially, the user won't even know about the screen. How would I make the window "transparent" to events?


Solution

  • Read the section from the Swing tutorial on Creating a Translucent Window.

    You would use an opacity of 0.0f.

    Edit:

    With an opacity of 0.0f the events go through the frame to the component below, therefore the window you click on will come to the front.

    With a non-zero opacity (ie 0.05f) the events are intercepted by the frame.

    You may also need to use:

    frame.setAlwaysOnTop( true );
    

    to prevent the window from coming to the front.

    Play with the opacity and always on top property to get your desired effect. If these two properties don't work then I have no ideas to do what you are asking, nor do I understand the requirement.