I'm trying to make JavaFX strings Unselectable
, NoFocusTraversable
, but I have no luck. Below is the code for another question that you can use for the game. I added two custom lines to make some lines no focus traversable
.
Although I cannot make certain Unselectable
strings, any ideas?
You will need to load the TomasMikula / EasyBind library (or comment on the top lines and uncomment the bottom lines inside the RowFactory
)
The code comes from ( JavaFX: how to disable a row in a TableView? ) Answer to StackOverflow:
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.function.Function; import javafx.application.Application; import javafx.beans.binding.Bindings; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ContentDisplay; import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableRow; import javafx.scene.control.TableView; import javafx.scene.layout.BorderPane; import javafx.stage.Stage; import org.fxmisc.easybind.EasyBind; public class DisabledTableRowExample extends Application { @Override public void start(Stage primaryStage) { TableView<Item> table = new TableView<>(); table.getItems().addAll(createData()); TableColumn<Item, Item> deleteCol = createTableColumn("Delete", ReadOnlyObjectWrapper<Item>::new); deleteCol.setCellFactory(this::createDeleteCell); table.getColumns().addAll(Arrays.asList( createTableColumn("Name", Item::nameProperty), createTableColumn("Value", Item::valueProperty), deleteCol ));
source share