JDK-8222457 : TabPane doesn't respect order of TabPane.getTabs() list
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8u192,openjfx13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2019-03-12
  • Updated: 2020-07-02
  • Resolved: 2019-06-28
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
openjfx13Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
C:\Users\hwaite>ver

Microsoft Windows [Version 6.1.7601]

C:\Users\hwaite>java -version
java version "1.8.0_192"
Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)

A DESCRIPTION OF THE PROBLEM :
TabPane.getTabs().setAll(permutatedTabs) fails to reorder tabs. Thus, it's not possible to permutate TabPane.getTabs() in a single call. ListChangeListener should do more than just reset Tab's TabPane reference. This should probably mimic TableView/TableColumn behavior.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run application and press 'Swap' button.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Tabs switch places.
ACTUAL -
Nothing happens.

---------- BEGIN SOURCE ----------
public class Test extends Application {
  public static void main(String[] pArgs) {launch(pArgs);}

  @Override public void start(Stage pStage) throws IOException {
    final Tab tabA = new Tab("Alpha", new Label("Alpha"));
    final Tab tabB = new Tab("Bravo", new Label("Bravo"));
    final TabPane tabPane = new TabPane(tabA, tabB);

    final Button btn = new Button("Swap");
    btn.setOnAction(
      pEvt -> {
        tabPane.getTabs().setAll(
          tabPane.getTabs().get(1), tabPane.getTabs().get(0)
        );
      }
    );

    pStage.setScene(new Scene(new VBox(tabPane, btn), 850, 400));
    pStage.show();
  }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Remove and re-add tabs in separate calls.

FREQUENCY : always



Comments
Changeset: a30f08e154af Author: arapte Date: 2019-06-28 12:18 +0530 URL: http://hg.openjdk.java.net/openjfx/jfx-dev/rt/rev/a30f08e154af 8222457: TabPane doesn't respect order of TabPane.getTabs() list Reviewed-by: kcr, aghaisas
28-06-2019

Thanks Kevin & Ajit, I shall make corrections according to your comments and push it.
26-06-2019

import javafx.util.Pair; -- This statement can be moved to appropriate place to keep imports sorted. Rest changes look good. +1.
26-06-2019

Thanks for the review Kevin, Please take a look at the corrected change: http://cr.openjdk.java.net/~arapte/fx/8222457/webrev.01/
25-06-2019

Looks good, other than a white-space problem you introduced: tests/system/src/test/java/test/robot/javafx/scene/TabPanePermuteGetTabsTest.java:193: Trailing whitespace +1, pending that fix This needs a second reviewer. [~aghaisas] can you review?
25-06-2019

The fix looks good. I ran the test and it correctly fails if the fix isn't applied and passes if it is applied. A couple minor comments on the test: 1. I recommend a more descriptive name than 'd' for the delta value to use when moving the mouse to the first tab. Also, as it is a constant, it can be static final 2. The tab and selectionLatch arrays can be instance variables.
24-06-2019

Hi all, Please review this fix: http://cr.openjdk.java.net/~arapte/fx/8222457/webrev.00/ Issue: When tabs are permuted as mentioned in the issue description, the tab headers do not get permuted. TabPane.getTabs() reflects the correct permuted tab sequence. Fix: The tab headers should be permuted as same as the sequence of tabs in TabPane.getTabs(). Verification: No tests fail due to this change. Added a new system test which tests 3 scenarios, test steps are described in test comments.
20-06-2019

The ObservableList returned by TabPane.getTabs() gets permuted but visually the tab sequence remains same. Looks like the wasRemoved() case is not handled.
16-04-2019

[~arapte] can you check whether this happens on openjfx13 as well?
15-04-2019