JDK-8237602 : TabPane doesn't respect order of TabPane.getTabs() list
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx13
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2020-01-20
  • Updated: 2020-08-11
  • Resolved: 2020-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
openjfx15Fixed
Related Reports
Duplicate :  
Relates :  
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



Comments
Submitter confirmed, "tested with OpenJFX 15-ea+8 and I confirm that the issue has been resolved."
11-08-2020

Changeset: 6e039302 Author: Ambarish Rapte <arapte@openjdk.org> Date: 2020-05-18 10:25:19 +0000 URL: https://git.openjdk.java.net/jfx/commit/6e039302
18-05-2020