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

[TabPane] Sorting tabs makes tab selection menu empty

    XMLWordPrintable

Details

    • x86_64
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_92"
      Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      When the tabs are sorted, the tab selection menu gets empty.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a TabPane with several tabs so that all tabs do not fit into the window, and a tab selection menu button appears at the right of the tab header.
      2. Sort the tabs:
      tabPane.getTabs().sort((o1, o2) -> o2.getText().compareTo(o1.getText()));


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Tab selection menu contains all tabs' names
      ACTUAL -
      Tab selection menu is empty

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class TabPaneTest extends Application {

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

          int i = 1;

          @Override
          public void start(Stage primaryStage) throws Exception {
              TabPane tabPane = new TabPane();
              tabPane.setSkin(new MyTabPaneSkin(tabPane));

              tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));

              Button add = new Button("Add new tab");
              add.setOnAction(event -> {
                  tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));
              });

              Button addSort = new Button("Add new tab & sort");
              addSort.setOnAction(event -> {
                  tabPane.getTabs().add(new Tab("My beautiful tab " + i, new TextArea("pane " + (i++))));
                  tabPane.getTabs().sort((o1, o2) -> o2.getText().compareTo(o1.getText()));
              });
              Button sort = new Button("Sort tabs");
              sort.setOnAction(event -> {
                  tabPane.getTabs().sort((o1, o2) -> o2.getText().compareTo(o1.getText()));
              });

              VBox vbox = new VBox(tabPane, new HBox(add, addSort, sort));

              primaryStage.setScene(new Scene(vbox));
              primaryStage.setWidth(400);
              primaryStage.setHeight(300);
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      As a workaround, one might remove all tabs, sort the list, and then add them back:

                  List<Tab> tabs = Lists.newArrayList(tabPane.getTabs());
                  tabs.sort((o1, o2) -> o2.getText().compareTo(o1.getText()));
                  tabPane.getTabs().clear();
                  tabPane.getTabs().setAll(tabs);



      Attachments

        Issue Links

          Activity

            People

              arapte Ambarish Rapte
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: