JavaFX-TableView-Selection

IF you looking at the current version of the „ObservableList“ there is a „size()“ method but no binding for it.

If you want to bind the current count of selections to a Label you need listener 🙁

A other way is this:

[codesyntax lang=“java“]

        TableView<DemoVO> table = TableHelper.createDummyTable();

	Label label = new Label();

	// Liste aller Items
	ListExpression<DemoVO> completeList = new ReadOnlyListWrapper<>(table.getItems());
	// Selektionen
	ListExpression<DemoVO> selection = new ReadOnlyListWrapper<>(table.getSelectionModel().getSelectedItems());
	// Text erstellen
	label.textProperty().bind(Bindings.concat(selection.sizeProperty()).concat("/").concat(completeList.sizeProperty()));

[/codesyntax]

 

A complete File can be found here: https://github.com/Scavenger156/JavaFx-TC/tree/master/FxTricks