Ability to click through a java app

后端 未结 3 419
暖寄归人
暖寄归人 2021-01-03 08:08

I\'ve got a simple program which atm displays a transparant window with an image on it, which is always on top of other windows. Is it possible to direct input past my app s

相关标签:
3条回答
  • 2021-01-03 08:34

    You can click through a JFrame with this code...

    AWTUtilities.setWindowOpaque(this, false);
    AWTUtilities.setWindowOpacity(this, 0.8f);
    
    0 讨论(0)
  • 2021-01-03 08:45

    I don't think you can do it easily, this because after that your OS has dispatched the mouse click to the Java application you can't dispatch that again back to activate whatever is beneath the Java application.

    You could do it easily if everything is inside just one Java application but not with separate environments.

    0 讨论(0)
  • 2021-01-03 08:49

    Using JNA's WindowUtils accomplishes this effect on Windows 7 (other systems untested):

    JFrame frame = new JFrame();
    //...
    frame.setAlwaysOnTop(true);
    System.setProperty("sun.java2d.noddraw", "true");
    WindowUtils.setWindowTransparent(frame, true);
    WindowUtils.setWindowAlpha(frame, 0.6f);
    

    Thanks to Nate's comment about setAlwaysOnTop for making this a more viable option.

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