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

Context Menu of Tab is not well displayed on second right-click.

XMLWordPrintable

    • x86
    • windows_7

      Run this sample test, you don't need an actual "test.css" in the project.

      "import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.ContextMenu;
      import javafx.scene.control.MenuItem;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabBuilder;
      import javafx.scene.control.TabPane;
      import javafx.scene.control.TabPaneBuilder;
      import javafx.stage.Stage;

      public class TestTabPane extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(Stage paramStage) throws Exception {
              TabPane tabPane = TabPaneBuilder.create().build();
              for (int i = 1; i <= 10; i++) {
                  tabPane.getTabs().add(buildTab("tab" + i));
              }
              Scene scene = new Scene(tabPane, 300, 275);
              scene.getStylesheets().add("test.css");
              paramStage.setScene(scene);
              paramStage.show();
          }

          public Tab buildTab(String name) {
              final Tab tab = TabBuilder.create().closable(true).build();
              tab.setText(name);
              ContextMenu contextMenu = new ContextMenu();
              contextMenu.getItems().add(new MenuItem("test"));
              tab.setContextMenu(contextMenu);
              return tab;
          }
      }
      "

      Run the sample
      Right-click on tab1 header, contextMenu is displayed properly.
      Right-click again on tab1 header (while the contextMenu is still displayed), the first contextMenu is hidden, a new ContextMenu is shown, but that time, the right and bottom edge are cut.

      I really don't know why it is happening. Only thing I know is that adding a Stylesheet (present in the project or not) in the Scene cause that issue.

      Tested with JDK8u112.

            jgiles Jonathan Giles
            shadzic Samir Hadzic
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: