2 Replies Latest reply: Apr 21, 2013 6:29 PM by KonradZuse RSS

    How to integrate javaFX gesture management in a complex Swing application?

    1003100
      Hi all,
      I have to insert ZOOM and SWIPE gesture-management in a complex Swing application, based on a big SVG JPanel.
      I've tried something like following java code but it doesn't work; can anyone help me?
      Thanks in advance

      Ricky

      public class SvgPanel extends JPanel {
      private JFXPanel jfxPanel_ = null;
      private Scene sceneSVG_ = null;

      public SvgPanel() {
      super(null);
      ...
      extendsToFXEvents();
      }

      private void extendsToFXEvents() {
      jfxPanel_ = new JFXPanel();
      this.add(jfxPanel_); // where "this" is my JPanel
      Platform.runLater(new Runnable() {
      @Override
      public void run(){
      initFX();
      }
      });
      }

      private void initFX(){
      Group root = new Group();
      sceneSVG_ = new Scene(root,1920,1200,javafx.scene.paint.Color.BLUE);
      jfxPanel_.setScene(sceneSVG_);
      jfxPanel_.setVisible(true);

      sceneSVG_.setOnZoomStarted(new EventHandler<ZoomEvent>() {
      @Override
      public void handle(ZoomEvent event) {
      System.out.println("SvgPanel - extendsToFXEvents - setOnZoomStarted");
      event.consume();
      }
      });

      sceneSVG_.setOnZoom(new EventHandler<ZoomEvent>() {
      @Override
      public void handle(ZoomEvent event) {
      System.out.println("SvgPanel - extendsToFXEvents - setOnZoom");
      event.consume();
      }
      });

      sceneSVG_.setOnZoomFinished(new EventHandler<ZoomEvent>() {
      @Override
      public void handle(ZoomEvent event) {
      System.out.println("SvgPanel - extendsToFXEvents - setOnZoomFinished");
      event.consume();
      }
      });
      }