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

Removing and instantly re-adding a Tab to the same TabPane does not work

XMLWordPrintable

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

      Running this attached code and hitting the button makes the first Tab vanish

      package controls;

      import com.sun.javafx.scene.control.skin.TabPaneSkin;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Skin;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Priority;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.stage.Stage;

      public class PlaneSampleTabPane extends Application {

      @Override
      public void start(Stage primaryStage) throws Exception {
      HBox h = new HBox();
      Scene s = new Scene(h, 400, 400);

      TabPane tb = new TabPane();

      {
      Tab tab = new Tab("Tab 1");
      Rectangle r = new Rectangle(100, 100);
      r.setFill(Color.GREEN);
      tab.setContent(new BorderPane(r));
      tb.getTabs().add(tab);
      }

      {
      Tab tab = new Tab("Tab 2");
      Rectangle r = new Rectangle(100, 100);
      r.setFill(Color.GREEN);
      tab.setContent(new BorderPane(r));
      tb.getTabs().add(tab);
      }

      HBox.setHgrow(tb, Priority.ALWAYS);
      h.getChildren().add(tb);

      Button b = new Button("Reorder");
      b.setOnAction((e) -> {
      Tab t = tb.getTabs().get(0);
      tb.getTabs().remove(t);
      tb.getTabs().add(t);
      });
      h.getChildren().add(b);

      primaryStage.setScene(s);
      primaryStage.show();

      }

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

            jgiles Jonathan Giles
            tschindl Tom Schindl
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: