- If you can only act within the form, then you need to make the form full screen (maximized), but not fullScreen - the contexts are different.
- Dale, you need to catch both mouse events and transmit them far - through the form.
The search led me to an awt solution: https://stackoverflow.com/questions/1190168/pass-mouse-events-to-applications-behind-from-a-java-ui
Next - the code from the discussion on the link:
import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JFrame; import javax.swing.JPanel; public class ClickThrough { public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JFrame f = new JFrame("Test"); f.setAlwaysOnTop(true); Component c = new JPanel() { @Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D)g.create(); g2.setColor(Color.gray); int w = getWidth(); int h = getHeight(); g2.fillRect(0, 0, w,h); g2.setComposite(AlphaComposite.Clear); g2.fillRect(w/4, h/4, w-2*(w/4), h-2*(h/4)); } }; c.setPreferredSize(new Dimension(300, 300)); f.getContentPane().add(c); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); com.sun.awt.AWTUtilities.setWindowOpaque(f,false); } }
And a note from the same place: you need to use the undecorated window (without the status bar, the maximize / minimize buttons, and so on), otherwise it will not work.
With JavaFX for now I try to repeat the same. It will turn out - I will add the answer.