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

Tabs don't appear when removed and added again to TabPane

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u20
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:
    • Environment:

      Java 8u20, Windows 7 x64

      Description

      Because there is no visible-property, I try to show/hide tabs by adding/removing them from the tabPane.

      However, in Java 8u20, the tabs don't reappear after adding them again.

      The following code can be used to reproduced the bug:

      {code}
      package be.iminds.ilabt.jfed.experimenter_gui;
      /**
       * User: twalcari
       * Date: 11/10/2014
       * Time: 16:15
       */

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      import java.util.Random;

      public class TabsTest extends Application {

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

          @Override
          public void start(Stage primaryStage) {

              BorderPane container = new BorderPane();
              container.setPrefSize(600, 400);

              TabPane tabPane = new TabPane();
              container.setCenter(tabPane);

              Tab[] tabs = new Tab[5];

              for (int i = 0; i < tabs.length; i++) {
                  tabs[i] = new Tab("Tab " + i);
                  tabs[i].setContent(new Label("Content of Tab " + i));

                  tabPane.getTabs().add(tabs[i]);
              }

              Button button = new Button("Remove and add tab again");
              container.setBottom(button);

              button.setOnAction(ae -> {
                  int index = new Random().nextInt(tabs.length);
                  System.out.println("Removing and adding tab " + index);

                  tabPane.getTabs().remove(tabs[index]);
                  tabPane.getTabs().add(tabs[index]);
              });

              primaryStage.setScene(new Scene(container));
              primaryStage.show();
          }
      }

      {code}



       Also, the last tab disappears in the process (ex. after "Tab 2" is removed and added again, "Tab 4" disappears too)

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: