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

[SwingNode] JEditorPane in SwingNode inside TabPane does not get focus properly when clicked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u20
    • 8u5
    • javafx
    • Java 8u5 32-bit, Ubuntu 14.04, and also Mac OS X 10.9.2, Java 8u5

      If you have a JavaFX Stage with a JavaFX TabPane in it, and you add as one of the tabs a SwingNode containing a JEditorPane, clicking in the editor does not give focus to the editor as you would expect, but instead seems to give focus to the tab (the label in the tab header).

      On Ubuntu 14.04 (Java 8u5), clicking always gives focus to the tab and never to the editor pane. On Mac OS X 10.9.2, clicking first gives focus to the editor, but clicking a second time gives focus to the tab. Third time to the editor again, fourth to the tab, and so on.

      Minimal Example:

      import javafx.application.Application;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.embed.swing.SwingNode;
      import javax.swing.JEditorPane;


      public class Example extends Application
      {
          public void start(Stage stage)
          {
              TabPane tabPane = new TabPane();
              Scene scene = new Scene(tabPane, 640, 480);
              stage.setScene(scene);

              Tab javafxTab = new Tab();
              javafxTab.setText("Editor");
              SwingNode swingNode = new SwingNode();
              swingNode.setContent(new JEditorPane("text/plain", "Try\nand\nclick\nin\nhere"));
              javafxTab.setContent(swingNode);
              tabPane.getTabs().add(javafxTab);

              stage.show();
          }
      }

            anthony Anthony Petrov (Inactive)
            nbrownjfx Neil Brown (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: