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

The columnPopupMenu of the TableHeaderRow is not updated when adding columns to a nested column

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u60
    • 8u40
    • javafx
    • Windows 7

    Description

      When adding a column to a column then the table header menu used to display/hide columns is not updated. As soon as a topmost column is moved to an other position the menu will be updated.

      Reproducer:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

      public class TableViewHeaderMenuBug extends Application {

      private int colCount = 1;

      private void init(BorderPane root) {
      TableView table = new TableView<>();
      table.setTableMenuButtonVisible(true);
      root.setCenter(table);

      // Top columns
      TableColumn topCol1 = new TableColumn("Top Col 1");
      TableColumn topCol2 = new TableColumn("Top Col 2");
      table.getColumns().addAll(topCol1, topCol2);

      // Subcolumns
      TableColumn<?, ?> subCol11 = new TableColumn("Col 1.1");
      TableColumn<?, ?> subCol12 = new TableColumn("Col 1.2");
      topCol1.getColumns().addAll(subCol11, subCol12);

      TableColumn<?, ?> subCol20 = new TableColumn("Col 2.0");
      topCol2.getColumns().add(subCol20);

      Button addColButton = new Button("Add Sub Column");
      addColButton.onActionProperty().set(event -> {
      TableColumn col = new TableColumn("Col 2." + colCount);
      colCount++;
      topCol2.getColumns().add(col);
      });

      root.setBottom(addColButton);
      }

      @Override
      public void start(Stage primaryStage) {
      try {
      BorderPane root = new BorderPane();
      init(root);
      Scene scene = new Scene(root, 400, 400);
      primaryStage.setScene(scene);
      primaryStage.show();
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

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

      Start the reproducer. You will see a table with nested columns. Check the table header menu on the right side of the table header (+). It will contain 3 entries.
      Press the "Add Sub Columns" button on the bottom of the window some times to add sub-columns to Top Col 2. Check the table header menu again. It still shows 3 entries.
      Move Top Col 2 to column index 0. Now the table header menu will be updated.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported: