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

Tab not closed correctly in TabPane when animation is Off

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • jfx11
    • 8u60
    • javafx
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) Client VM (build 25.60-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      After removing all tabulation in a tabpane except last one, phantom tabulation are still visible on tabPane if animation if ff

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Launch the sample below.
      - click on "Add 50 tab"'
      - click on "closeAllExceptLast"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      All tabulation should be closed exect last one
      ACTUAL -
      Phamtom tab header are left visible.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * To change this license header, choose License Headers in Project Properties.
       * To change this template file, choose Tools | Templates
       * and open the template in the editor.
       */
      package tabpanebug;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.control.ToolBar;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.VBox;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      /**
       *
       * @author Daniel
       */
      public class TabPaneBug extends Application {

          int i = 0;

          @Override
          public void start(Stage primaryStage) {
              TabPane tabPane = new TabPane();
              tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS);
              tabPane.setStyle("-fx-open-tab-animation:none;-fx-close-tab-animation:none;");
              Button addTab = new Button("add 50 Tab");
              addTab.setOnAction((ActionEvent event) -> {
                  for (int z = 0; z < 50; z++) {
                      VBox content = new VBox();
      // for (int j = 0; j < 100; j++) {
                          content.getChildren().add(new VBox(10, new Text("tab" + i), new Text("type something"), new Rectangle(50, 20)));
      // }
                      tabPane.getTabs().add(new Tab("tab" + i++, content));
                  }
              });
              Button closeAll = new Button("closeAll");
              closeAll.setOnAction((ActionEvent event) -> {
                  tabPane.getTabs().clear();
              });
              Button closeAllExceptLast = new Button("closeAllExceptLast");
              closeAllExceptLast.setOnAction((ActionEvent event) -> {
                  tabPane.getTabs().retainAll(tabPane.getTabs().get(tabPane.getTabs().size() - 1));
              });
              Button closeAllExceptFisrt = new Button("closeAllExceptFisrt");
              closeAllExceptFisrt.setOnAction((ActionEvent event) -> {
                  tabPane.getTabs().retainAll(tabPane.getTabs().get(0));
              });
              BorderPane root = new BorderPane();
              root.setTop(new ToolBar(addTab, closeAll, closeAllExceptFisrt, closeAllExceptLast));
              root.setCenter(tabPane);

              Scene scene = new Scene(root, 300, 250);

              primaryStage.setTitle("TabPaneBug");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

         

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Never remove animation.

      In the example above, comment the style :

            // tabPane.setStyle("-fx-open-tab-animation:none;-fx-close-tab-animation:none;");


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

              Created:
              Updated:
              Resolved: