import helloworld.HelloTableView.Person; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; /** * * @author Jonathan */ public class Main extends Application { public static void main(String... arg) { launch(arg); } public void start(Stage primaryStage) throws Exception { Group rootGroup = new Group(); Scene scene = new Scene(rootGroup, 800, 600); primaryStage.setScene(scene); ObservableList testItems = FXCollections.observableArrayList(); testItems.addAll( //// // sources for names: //// // http://www.ssa.gov/OACT/babynames/ //// // http://names.mongabay.com/most_common_surnames.htm //// new Person("Jacob", "Smith", "jacob.smithexample.com" ), new Person("Isabella", "Johnson", "isabella.johnsonexample.com" ), new Person("Ethan", "Williams", "ethan.williamsexample.com" ), new Person("Emma", "Jones", "emma.jonesexample.com" ), new Person("Michael", "Brown", "michael.brownexample.com" ), new Person("Olivia", "Davis", "olivia.davisexample.com" ), new Person("Alexander", "Miller", "alexander.millerexample.com" ), new Person("Sophia", "Wilson", "sophia.wilsonexample.com" ), new Person("William", "Moore", "william.mooreexample.com" ), new Person("Ava", "Taylor", "ava.taylorexample.com" ), new Person("Joshua", "Anderson", "joshua.andersonexample.com" ), new Person("Emily", "Thomas", "emily.thomasexample.com" ), new Person("Daniel", "Jackson", "daniel.jacksonexample.com" ), new Person("Madison", "White", "madison.whiteexample.com" ), new Person("Jayden", "Harris", "jayden.harrisexample.com" ), new Person("Abigail", "Martin", "abigail.martinexample.com" ), new Person("Noah", "Thompson", "noah.thompsonexample.com" ), new Person("Chloe", "Garcia", "chloe.garciaexample.com" ), new Person("Anthony", "Martinez", "anthony.martinezexample.com" ), new Person("Mia", "Robinson", "mia.robinsonexample.com" ) // new Person("Jacob", "Smith" ), // new Person("Isabella", "Johnson" ), // new Person("Ethan", "Williams" ), // new Person("Emma", "Jones" ), // new Person("Michael", "Brown" ), // new Person("Olivia", "Davis" ), // new Person("Alexander", "Miller" ), // new Person("Sophia", "Wilson" ), // new Person("William", "Moore" ), // new Person("Ava", "Taylor" ), // new Person("Joshua", "Anderson" ), // new Person("Emily", "Thomas" ), // new Person("Daniel", "Jackson" ), // new Person("Madison", "White" ), // new Person("Jayden", "Harris" ), // new Person("Abigail", "Martin" ), // new Person("Noah", "Thompson" ), // new Person("Chloe", "Garcia" ), // new Person("Anthony", "Martinez" ), // new Person("Mia", "Robinson" ) ); TableView table = new TableView(); table.setItems(testItems); TableColumn testColumn = new TableColumn("Width"); // testColumn.setResizable(true); testColumn.setProperty("firstName"); // testColumn.setMaxWidth(100); TableColumn testColumn2 = new TableColumn("Height"); // testColumn2.setResizable(true); testColumn2.setProperty("lastName"); testColumn2.setMinWidth(100); table.getColumns().addAll(testColumn, testColumn2); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); BorderPane mainPane = new BorderPane(); mainPane.setCenter(table); scene.setRoot(mainPane); primaryStage.centerOnScreen(); primaryStage.setVisible(true); } }