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

TableViews with many columns lose alignment between headers and cells

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 9
    • None
    • javafx
    • None

    Description

      Steps to reproduce:

      1) Run test code below
      2) Scroll horizontally to right-most position
      3) Note that the column headers no longer align to the cell borders

      import java.util.stream.Collectors;
      import java.util.stream.IntStream;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class FXTableViewExample10 extends Application {
          public static void main(String [] args) {
              Application.launch(args);
          }
           
          @Override
          public void start(Stage primaryStage) {
              TableView<Integer> table = new TableView<>();
              table.setFixedCellSize(24);
               
              // rows
              table.getItems().addAll(IntStream.range(0, 100).boxed().collect(Collectors.toList()));
               
              // columns & cells
              for (int j=0; j<100; j++) {
                  int colNr = j;
                  TableColumn<Integer, String> col = new TableColumn<>(String.format("Col %02d", j));
                  col.setCellValueFactory(feat -> new SimpleStringProperty(String.format("%02d.%02d", colNr, feat.getValue())));
                  table.getColumns().add(col);
              }
               
              Scene scene = new Scene(table, 500, 475);
              primaryStage.setScene(scene);
              primaryStage.show();
          }
      }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: