import javafx.application.Application; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class TableWithTextHeaders extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName")); TableView table = new TableView(); table.getColumns().addAll(firstNameCol, lastNameCol); table.setItems(FXCollections.observableArrayList( new Person("Jacob", "Smith"), new Person("Isabella", "Johnson"), new Person("Ethan", "Williams") )); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); StackPane layout = new StackPane(); layout.setStyle("-fx-padding: 10;"); layout.getChildren().add(table); Scene scene = new Scene(layout); stage.setScene(scene); stage.show(); System.getProperties().list(System.out); } public static class Person { private final SimpleStringProperty firstName; private final SimpleStringProperty lastName; private Person(String fName, String lName) { this.firstName = new SimpleStringProperty(fName); this.lastName = new SimpleStringProperty(lName); } public String getFirstName() { return firstName.get(); } public void setFirstName(String fName) { firstName.set(fName); } public String getLastName() { return lastName.get(); } public void setLastName(String fName) { lastName.set(fName); } } }