I'm not sure this is actually a bug but I'll describe anyway and let you guys decide.
In the code below I have one column that contains 20 child columns. When displaying the columns a horizontal scroll bar appears as they are too wide for the stage. Because the column header text is centred, it isn't visible for the parent column until you scroll to the right. I would expect the text to be visible no matter what the scroll position.
I'm sure I can use a custom component to get this behaviour but maybe it should happen by default?
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.List;
public class MultipleColumnsTest extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane pane = new BorderPane();
Scene scene = new Scene(pane, 500, 500);
stage.setScene(scene);
int numColumns = 20;
TableView<String[]> table = new TableView<>();
TableColumn<String[],String> topColumn = new TableColumn<>("Top Column Name");
for (int i = 0; i < numColumns; i++) {
final int column = i;
TableColumn<String[], String> childColumn = new TableColumn<>("Child Column " + i);
childColumn.setCellValueFactory(stringCellDataFeatures -> new ReadOnlyStringWrapper(stringCellDataFeatures.getValue()[column]));
topColumn.getColumns().add(childColumn);
}
int numRows = 50;
List<String[]> data = new ArrayList<>(numRows);
for (int j = 0; j < numRows; j++) {
String[] row = new String[numColumns];
for (int i = 0; i < numColumns; i++) {
row[i] = "(" + j + ", " + i + ")";
}
data.add(row);
}
table.setItems(FXCollections.observableArrayList(data));
table.getColumns().add(topColumn);
pane.setCenter(table);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
In the code below I have one column that contains 20 child columns. When displaying the columns a horizontal scroll bar appears as they are too wide for the stage. Because the column header text is centred, it isn't visible for the parent column until you scroll to the right. I would expect the text to be visible no matter what the scroll position.
I'm sure I can use a custom component to get this behaviour but maybe it should happen by default?
import javafx.application.Application;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.collections.FXCollections;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.List;
public class MultipleColumnsTest extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane pane = new BorderPane();
Scene scene = new Scene(pane, 500, 500);
stage.setScene(scene);
int numColumns = 20;
TableView<String[]> table = new TableView<>();
TableColumn<String[],String> topColumn = new TableColumn<>("Top Column Name");
for (int i = 0; i < numColumns; i++) {
final int column = i;
TableColumn<String[], String> childColumn = new TableColumn<>("Child Column " + i);
childColumn.setCellValueFactory(stringCellDataFeatures -> new ReadOnlyStringWrapper(stringCellDataFeatures.getValue()[column]));
topColumn.getColumns().add(childColumn);
}
int numRows = 50;
List<String[]> data = new ArrayList<>(numRows);
for (int j = 0; j < numRows; j++) {
String[] row = new String[numColumns];
for (int i = 0; i < numColumns; i++) {
row[i] = "(" + j + ", " + i + ")";
}
data.add(row);
}
table.setItems(FXCollections.observableArrayList(data));
table.getColumns().add(topColumn);
pane.setCenter(table);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}