When a table has padding or the skin is overridden and modifies the x and y values of the layoutChildren() method, the column drag header, overlay and line are not correctly aligned.
This is because the relocation of these components ignore the x and y value from the table component. These should be included because they contain the snapped padding or other changed values.
For example, one use case where you might override layoutChildren() and modify the x and y values is when you want to add a table header on top of the table. The table header row is correctly shifted down, but the column overlay and line are not (visible when dragging).
The drag header on the other hand relocate itself too much because it calculates the table padding in although even though it shouldn't because the position is based on the column header of the table (not the table itself).
Example:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
TableView<String> tableView = new TableView<>();
tableView.setPadding(new Insets(5, 70, 15, 50));
for (int i = 0; i < 10; i++) {
tableView.getColumns().add(new TableColumn<>("col" + i));
}
Parent root = new StackPane(tableView);
Scene scene = new Scene(root, 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Note that if you drag a column the drag header, column overlay (gray) and the column line (blue) are not positioned correctly.
This is because the relocation of these components ignore the x and y value from the table component. These should be included because they contain the snapped padding or other changed values.
For example, one use case where you might override layoutChildren() and modify the x and y values is when you want to add a table header on top of the table. The table header row is correctly shifted down, but the column overlay and line are not (visible when dragging).
The drag header on the other hand relocate itself too much because it calculates the table padding in although even though it shouldn't because the position is based on the column header of the table (not the table itself).
Example:
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class Test extends Application {
@Override
public void start(Stage primaryStage) {
TableView<String> tableView = new TableView<>();
tableView.setPadding(new Insets(5, 70, 15, 50));
for (int i = 0; i < 10; i++) {
tableView.getColumns().add(new TableColumn<>("col" + i));
}
Parent root = new StackPane(tableView);
Scene scene = new Scene(root, 600, 400);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Note that if you drag a column the drag header, column overlay (gray) and the column line (blue) are not positioned correctly.
- links to
-
Commit openjdk/jfx/2ec33435
-
Review(master) openjdk/jfx/1193