Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaFX 2.2 : How to forward mouse event to a Swing component under a JFXPanel in a JLayeredPane?
    primarykey
    data
    text
    <p>In my application, I want to have a Swing panel with JavaFX control over it. For that, I use a JLayeredPane in which I insert a JPanel and a JFXPanel with a Scene that is not filled (aka <code>setFill(null)</code>). But no event passes through transparent areas of the JFXPanel to the Swing panel.</p> <p>Is there any solution to this problem ?</p> <p>Thanks</p> <p>Here an example :</p> <pre><code> public class TestJavaFX { private static JButton button; private static JFXPanel javafxPanel; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initAndShowGUI(); } }); } public static void initAndShowGUI() { JFrame frame = new JFrame("Swing application"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); javafxPanel = new JFXPanel(); button = new JButton("Swing - Push me"); JLayeredPane pane = new JLayeredPane(); pane.add(button, JLayeredPane.DEFAULT_LAYER); pane.add(javafxPanel, JLayeredPane.PALETTE_LAYER); pane.addComponentListener(new ComponentListener() { @Override public void componentShown(ComponentEvent e) { } @Override public void componentResized(ComponentEvent e) { button.setBounds(20, 50, 150, 30); javafxPanel.setBounds(0, 0, e.getComponent().getWidth(), e.getComponent().getHeight()); } @Override public void componentMoved(ComponentEvent e) { } @Override public void componentHidden(ComponentEvent e) { } }); frame.getContentPane().add(pane, BorderLayout.CENTER); Platform.runLater(new Runnable() { public void run() { createScene(); } }); // Show frame. frame.setSize(600, 400); frame.setVisible(true); } private static void createScene() { Button btn = new Button(); btn.setText("JavaFX - Push me"); VBox pane = new VBox(); pane.getChildren().add(btn); Scene scene = new Scene(pane); scene.setFill(null); javafxPanel.setScene(scene); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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