Is there a way to use JavaFX touch events in a swing application? I am currently using JFXPanel to capture JavaFX events, however, when I try to receive events, I do not receive any touch events and only mouse events. This is tested on the Dell Windows 8.1 Dell Touchscreen.
Updated: The code below is the skeleton of what I use to receive events. This JFXPanel is used as glass glass in a Swing application. This creates a JFXPanel for glass glass that is capable of capturing all events.
public class MouseEventRouter extends JFXPanel { ... public ZeusMouseEventRouter(JMenuBar menuBar, Container contentPane) { ... this._contentPane = contentPane; this._contentPane.add(_JFXpanel); this._contentPane.setVisible(true); init(); } private void init() { pane = new VBox(); pane.setAlignment(Pos.CENTER); Platform.runLater(this::createScene); } private void createScene() { Scene scene = new Scene(pane); ... scene.setOnTouchPressed(new EventHandler<javafx.scene.input.TouchEvent>() { @Override public void handle(javafx.scene.input.TouchEvent event) { System.out.println("tap down detected"); } }); ... setScene(scene); } }
java swing javafx
Nick
source share