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

Can't add subcolumns dynamically

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      java version "1.8.0_73"
      Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Version 6.1.7601

      A DESCRIPTION OF THE PROBLEM :
      We discovered the bug when trying to add subcolumns dynamically via a changelistener. We rebuild the bug with the code below (adding it with an actionevent).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Add subcolumns dynamically on ActionEvent or binding

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Subcolumns will be added
      ACTUAL -
      Columns are added (see cells) but without a header

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See testing code below:

      import javafx.application.Application;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;


      public class MainNestedCols extends Application{

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

          @Override
          public void start(Stage stage) {
              Parent root = createRoot();
              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.setTitle("Bug Table Nested Columns Test");
              stage.show();
          }

          private Parent createRoot() {
              ObservableList<String> values = FXCollections.observableArrayList();
              values.addAll("Alice", "Bob");

              TableView<String> tableView = new TableView<>(values);

              TableColumn<String, String> column = new TableColumn<>("Col");
              column.setMinWidth(100);
              tableView.getColumns().add(column);

              Button button = new Button("Add");
              button.setOnAction(e -> {

                  TableColumn<String, String> nestedCol = new TableColumn<>("Subcol1");
                  column.getColumns().add(nestedCol);
              });

              VBox vBox = new VBox();
              vBox.getChildren().addAll(tableView, button);
              VBox.setVgrow(tableView, Priority.ALWAYS);
              return vBox;
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Bug does not occurr, when there is already atleast 1 subcolumn

            jgiles Jonathan Giles
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: