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

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

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Environment:

      Java8

      Description

      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();
      }
      });

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: