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

TabPane does not update the tab name correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u40
    • 8u20
    • javafx

      When there are more tabs in tabPane the arrow will show in the top right area, then click the arrow button and you can see the first one of tab name in the list cannot updated with the right tab name text.
      Please refer to the below code, thanks~


      import java.util.UUID;
      import java.util.concurrent.Executors;
      import java.util.concurrent.TimeUnit;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.scene.Scene;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.stage.Stage;

      public class TabPaneTest extends Application {
      public static void main(String[] args) {
      launch(args);
      }

      @Override
      public void start(Stage primaryStage) throws Exception {
      SimpleStringProperty tabText = new SimpleStringProperty("First Tab Name");
      updateTabText(tabText);

      TabPane tabPane = new TabPane();

      for (int i = 0; i < 10; i++) {
      Tab tab = new Tab("TabName_000000000000_" + i);
      if (i == 0) {
      tab.textProperty().bind(tabText);
      }
      tabPane.getTabs().add(tab);
      }

      Scene scene = new Scene(tabPane, 800, 600);
      primaryStage.setScene(scene);
      primaryStage.setTitle("Multiple Tabs of TabPane Test");
      primaryStage.show();
      }

      private void updateTabText(SimpleStringProperty tabText) {
      Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(() -> {
      Platform.runLater(() -> {
      tabText.set(UUID.randomUUID().toString());
      });
      }, 0, 5, TimeUnit.SECONDS);
      }

      }

            jgiles Jonathan Giles
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: