Mouse events blocked during DnD inside JFXPanel - bug or limitation?
Fisher, Robert
robert.fisher.ext at zeiss.com
Fri May 27 08:06:39 UTC 2016
Hi all,
When inside a JFXPanel, after DnD has been started on a node and content put the dragboard, mouse-exited events for the node do not fire until the drag gesture is over.
Is this a known bug, new bug, or a limitation of using Swing + FX together?
Check out the test program below. Any input would be appreciated.
Cheers,
Rob
public class Main extends Application {
// Set to true to test behaviour when embedded inside a JFXPanel.
private static final boolean EMBED_IN_SWING = true;
public static void main(String[] args) {
if (EMBED_IN_SWING) {
SwingUtilities.invokeLater(() -> {
JFXPanel jfxPanel = new JFXPanel();
JFrame frame = new JFrame();
frame.add(jfxPanel);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setVisible(true);
Platform.runLater(() -> {
Scene scene = createScene();
jfxPanel.setScene(scene);
});
});
} else {
launch(args);
}
}
@Override
public void start(Stage primaryStage) {
Scene scene = createScene();
primaryStage.setScene(scene);
primaryStage.show();
}
private static Scene createScene() {
Rectangle rectangle = new Rectangle(50, 50);
rectangle.hoverProperty().addListener((v, o, n) -> System.out.println("Hover property: " + n));
rectangle.addEventFilter(MouseEvent.MOUSE_ENTERED, event -> System.out.println("Mouse entered"));
rectangle.addEventFilter(MouseEvent.MOUSE_EXITED, event -> System.out.println("Mouse exited"));
rectangle.setOnDragDetected(event -> {
Dragboard db = rectangle.startDragAndDrop(TransferMode.COPY);
ClipboardContent content = new ClipboardContent();
content.putString("Hello World");
db.setContent(content);
event.consume();
});
StackPane stackPane = new StackPane(rectangle);
return new Scene(stackPane, 800, 600);
}
}
More information about the openjfx-dev
mailing list