I am trying to select multiple rows in javafx, but I do not want to use the keyboard (SHIFT) for this.it should be after I click on it, and when I click on another column, it should also be selected.
I check some other answers here, but I could not find something short and comfortable. Is there a shorter way to do this?
@FXML private static Logger logger = Logger.getLogger(MainFrameControl.class); public TableView<Box> boxTable; protected final ObservableList<Box> boxData = FXCollections.observableArrayList(); Service service = new ServiceImpl(); private Stage mainStage; public MainFrameControl(Stage mainStage) { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainFrame.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); this.mainStage = mainStage; Stage stage = new Stage(); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } ArrayList<Box> list = service.findAllBoxen(); TableColumn<Box, String> boxnameColumn = (TableColumn<Box, String>) boxTable.getColumns().get(0); boxnameColumn.setCellValueFactory(new PropertyValueFactory<Box, String>("boxName")); TableColumn<Box, String> sizeColumn = (TableColumn<Box, String>) boxTable.getColumns().get(1); sizeColumn.setCellValueFactory(new PropertyValueFactory<Box, String>("size")); TableColumn<Box, String> windowColumn = (TableColumn<Box, String>) boxTable.getColumns().get(2); windowColumn.setCellValueFactory(new PropertyValueFactory<Box, String>("window")); TableColumn<Box, String> costColumn = (TableColumn<Box, String>) boxTable.getColumns().get(3); costColumn.setCellValueFactory(new PropertyValueFactory<Box, String>("cost")); TableColumn<Box, String> locationColumn = (TableColumn<Box, String>) boxTable.getColumns().get(4); locationColumn.setCellValueFactory(new PropertyValueFactory<Box, String>("location")); TableColumn<Box, Boolean> beddingColumn = (TableColumn<Box, Boolean>) boxTable.getColumns().get(5); beddingColumn.setCellValueFactory(new PropertyValueFactory<Box, Boolean>("bedding")); boxTable.setItems(boxData);
java javafx tableview
Tolga tamer
source share