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

TabPane doesn't respect order of TabPane.getTabs() list

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux_ubuntu

      Description

      ADDITIONAL SYSTEM INFORMATION :
      This bugs is not a regression but probably exists from a long time and is not OS specific, it's a bug in the TabPaneSkin implementation.

      A DESCRIPTION OF THE PROBLEM :
      When updating the tabs in TabPane and passing a new list but with already existing tabs (eventually in a different order), the order of the tabs may not match the requested order.







      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the provided JavaFx application source code and press the "Tabs 1 to 4" button. The UI will display Tab 3, Tab4, Tab 1, Tab 2 instead of ab 1, Tab 2, Tab 3, Tab 4

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When pressing the button, the UI should display the tabs in this order: Tab 1, Tab 2, Tab 3 & Tab 4
      ACTUAL -
      When pressing the button, the UI actually displays the tabs in this order: Tab 3, Tab4, Tab 1, Tab 2

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class TabPaneBugApplication extends Application {

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

          @Override
          public void start(Stage primaryStage) {
              Tab tab1 = new Tab("Tab 1");
              Tab tab2 = new Tab("Tab 2");
              Tab tab3 = new Tab("Tab 3");
              Tab tab4 = new Tab("Tab 4");
              TabPane tabPane = new TabPane(tab1, tab2);

              Button button = new Button();
              button.setText("Tabs 1 to 4");
              button.setOnAction(event -> tabPane.getTabs().setAll(tab1, tab2, tab3, tab4));

              StackPane root = new StackPane();
              root.getChildren().setAll(tabPane, button);
              primaryStage.setScene(new Scene(root, 300, 250));
              primaryStage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      A workaround would be to never pass existing tabs again but always new tabs. This is however a develoment constraint that should'nt exist.

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arapte Ambarish Rapte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: