import static javafx.scene.control.SelectionMode.MULTIPLE;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;


/**
 * JavaFX App
 */
public class App extends Application {

final ObservableList<SimpleObjectProperty<Integer>> listitems = FXCollections.observableArrayList();
private static int ITEM_COUNT = 500000;

public App() {
for (int i = 0; i < ITEM_COUNT; ++i) {
listitems.add(new SimpleObjectProperty<>(i));
}
}

@Override
public void start(Stage primaryStage) {
final TableView<SimpleObjectProperty<Integer>> lv = new TableView<>();
final TableColumn<SimpleObjectProperty<Integer>, Integer> c = new TableColumn<>();
c.setCellValueFactory(TableColumn.CellDataFeatures::getValue);
lv.getColumns().add(c);
lv.setItems(listitems);

final HBox hbox = new HBox();
hbox.getChildren().add(lv);
primaryStage.setScene(new Scene(hbox));

lv.getSelectionModel().setSelectionMode(MULTIPLE);

primaryStage.show();
Platform.runLater(() -> {
long startMillis = System.currentTimeMillis();
lv.getSelectionModel().selectAll();
System.out.println("Select item count " + ITEM_COUNT + " took " + (System.currentTimeMillis() - startMillis));
startMillis = System.currentTimeMillis();
lv.getSelectionModel().clearSelection();
System.out.println("Deselect item count " + ITEM_COUNT + " took " + (System.currentTimeMillis() - startMillis));
System.exit(1);
});
}

public static void main(String[] args) {
Application.launch(args);
}
} 