When change the tab index, it will impact the other tab(s) and not show again[8u11 can work but NOT 8u20]. Please see the below code:
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
public class TabIndexChangeTest extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
TabPane tp = new TabPane();
tp.getTabs().addAll(new Tab("Tab 1"), new Tab("Tab 2"));
Scene scene = new Scene(tp, 600, 200);
stage.setScene(scene);
stage.setTitle("Change Tab Index Test");
stage.show();
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(() -> {
Platform.runLater(() -> {
Tab tab0 = tp.getTabs().get(0);
tp.getTabs().remove(0);
tp.getTabs().add(tab0);
});
}, 5, 5, TimeUnit.SECONDS);
}
}
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
public class TabIndexChangeTest extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
TabPane tp = new TabPane();
tp.getTabs().addAll(new Tab("Tab 1"), new Tab("Tab 2"));
Scene scene = new Scene(tp, 600, 200);
stage.setScene(scene);
stage.setTitle("Change Tab Index Test");
stage.show();
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(() -> {
Platform.runLater(() -> {
Tab tab0 = tp.getTabs().get(0);
tp.getTabs().remove(0);
tp.getTabs().add(tab0);
});
}, 5, 5, TimeUnit.SECONDS);
}
}