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

Table view column reordering does not always work when there are hidden columns

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • 9
    • 8u92
    • javafx
    • x86_64
    • windows_7

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      In a table view with some columns hidden, reordering the remaining columns does not work as expected in most of the cases. For instance, have a table view where every other column is hidden. Trying to move one of the visible columns found in the middle of the view seems to leave the column unaffected.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Have a table view with several columns.
      2. Hide some of the columns, for instance, every other column.
      3. Try to move one of the remaining columns a few positions in either direction.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The column is moved in the place indicated by the placeholder.
      ACTUAL -
      The column stays in the same place.
      (When the hidden columns are finally shown, it seems that the column used in the scenario is actually moved, but not in the expected location.)

      Use the provided sample code to see the issue in action:
      1. hide the columns marked in red
      2. try to move column 8 after column 12
      Expected: Column 8 is placed after column 12.
      Actual: Column 8 appears in the same place, until the hidden columns are shown again; then it appears after column 9.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.geometry.Pos;
      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.scene.layout.HBox;
      import javafx.stage.Stage;

      import java.util.ArrayList;
      import java.util.List;

      public class TableColumnReorderingIssue extends Application {
          @Override
          public void start(final Stage primaryStage) throws Exception {
              final List<TableColumn<String, ?>> columns = new ArrayList<>();
              final List<TableColumn<String, ?>> redColumns = new ArrayList<>();
              for (int i = 0; i < 20; i++) {
                  final TableColumn<String, Integer> column = new TableColumn<>("" + i);
                  if (i % 2 == 1) {
                      column.setStyle("-fx-background-color: #FF7777");
                      redColumns.add(column);
                  }
                  columns.add(column);
              }

              final TableView<String> tableView = new TableView<>();
              tableView.getColumns().setAll(columns);

              final Button button1 = new Button("Show red columns");
              button1.setOnAction(event -> redColumns.forEach(c -> c.setVisible(true)));
              final Button button2 = new Button("Hide red columns");
              button2.setOnAction(event -> redColumns.forEach(c -> c.setVisible(false)));

              final HBox buttonPane = new HBox(5, button1, button2);
              buttonPane.setPadding(new Insets(3));
              buttonPane.setAlignment(Pos.CENTER);

              final BorderPane root = new BorderPane();
              root.setCenter(tableView);
              root.setTop(buttonPane);

              primaryStage.setTitle("Table Column Reordering Issue");
              primaryStage.setScene(new Scene(root, 600, 400));
              primaryStage.setMaximized(true);
              primaryStage.show();
          }

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

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

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

              Created:
              Updated:
              Resolved: