Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096609

[SwingNode] Swing component in JavaFx swing node no right click event

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8u20
    • 8
    • javafx
    • Java8

      Swing JButton component of a SwingNode in a Scene mouse events not working.

      Env: Java 8
      Problem: right click is not triggered, the middle click is interpreted as right click ... Here is sample code:

      Platform.runLater(new Runnable() {

        @Override
        public void run() {


      HBox hb = new HBox();

      SwingNode n = new SwingNode();

      JButton b = new JButton("CLICK ME!!!");
      b.addMouseListener(new MouseAdapter() {
           public final void mousePressed(MouseEvent e) {
          boolean isLeftClick = SwingUtilities.isLeftMouseButton(e);
          boolean isRightClick = SwingUtilities.isRightMouseButton(e);
          if (isLeftClick)
             System.out.println("Left");
          if (isRightClick)
             System.out.println("Right");
              }
      });
      n.setContent(b);
      hb.getChildren().add(n);

      Stage stage = new Stage();

      Scene appScene = new Scene(hb,100, 100);

      stage.setScene(appScene);


      stage.show();
      }
      });

            anthony Anthony Petrov (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: