Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried to make fully "event-transparent" (click-through as you call it) window, but there seems to be some native restrictions on that trick.</p> <p>Check this window example:</p> <pre><code>public static void main ( String[] args ) { Window w = new Window ( null ); w.add ( new JComponent () { protected void paintComponent ( Graphics g ) { g.setColor ( Color.BLACK ); g.fillRect ( 0, getHeight () / 2 - 10, getWidth (), 20 ); g.fillRect ( getWidth () / 2 - 10, 0, 20, getHeight () ); } public Dimension getPreferredSize () { return new Dimension ( 100, 100 ); } public boolean contains ( int x, int y ) { return false; } } ); AWTUtilities.setWindowOpaque ( w, false ); AWTUtilities.setWindowOpacity ( w, 0.5f ); w.pack (); w.setLocationRelativeTo ( null ); w.setVisible ( true ); } </code></pre> <p>Window and component does NOT have any:</p> <ol> <li>Mouse listeners</li> <li>Mouse motion listeners</li> <li>Mouse wheel listeners</li> <li>Key listeners</li> </ol> <p>Also the component should ignore any kind of mouse events EVEN if there are any listeners due to the modified <code>contains</code> method.</p> <p>As you can see - the area where nothing is painted on the component is event-transparent, but the filled area is not. Unluckly i didn't find any workaround to change that behavior. Seems that some "low-level" java methods are blocking the events.</p> <p>And this is just a basic JComponent-based example. I don't even say about more complex Swing components like labels, buttons e.t.c. which might have their own event-listeners which could block events.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload