There is such a TableView that lists the files:

 public class OverLimitFilesLayoutController { private Stage OLFilesLayoutStage; public OverLimitFilesLayoutController() {} public ObservableList<File> currentOverLimitList = FXCollections.observableArrayList(); public ObservableList<OLLFile> oLLFileDataForView = FXCollections.observableArrayList(); @FXML private TableView<OLLFile> overLFilesTable; @FXML private TableColumn<OLLFile, String> fileNameColumn; @FXML private TableColumn<OLLFile, Long> fileSizeColumn; @FXML private TableColumn<OLLFile, String> filePathColumn; @FXML private TableColumn<OLLFile, String> fileActions; @FXML public void initialize() { initDataForView(currentOverLimitList); //Преобразуем данные для отображения в таблице // устанавливаем тип и значение которое должно хранится в колонке fileNameColumn.setCellValueFactory(new PropertyValueFactory<OLLFile, String>("fileName")); fileSizeColumn.setCellValueFactory(new PropertyValueFactory<OLLFile, Long>("fileSize")); filePathColumn.setCellValueFactory(new PropertyValueFactory<OLLFile, String>("filePath")); fileActions.setCellValueFactory(new PropertyValueFactory<OLLFile, String>("fileActions")); //Заполняем таблицу данными overLFilesTable.setItems(oLLFileDataForView); } public void initDataForView (ObservableList<File> currentOverLimitList) { for (int i = 0; i < currentOverLimitList.size(); i++) { oLLFileDataForView.add(new OLLFile(currentOverLimitList.get(i).getName(), currentOverLimitList.get(i).length()/1024, currentOverLimitList.get(i).getAbsolutePath(), currentOverLimitList.get(i).getAbsolutePath())); } } //Setters and Getters public void setCurrentOverLimitList(ObservableList<File> currentOverLimitList) { this.currentOverLimitList = currentOverLimitList; } public ObservableList<File> getCurrentOverLimitList() { return currentOverLimitList; } public void setDialogStage(Stage OLFilesLayoutStage) { this.OLFilesLayoutStage = OLFilesLayoutStage; } 

In fileActions (while temporarily converted into a String ) I want to display a hyperlink that will translate to the folder with the file - and so on in each line in this field of the table.

Tell me where can I find an example of similar generation of links in a table?

    1 answer 1

    In order for you to perform any action when you click, you need to transfer a cellFactory to the fileActions column, in which you will describe what to do if you clicked on this cell, and then call the Desktop.open (file) T method . the code will look something like this

     @FXML public void initialize() { ... fileActions.setCellValueFactory(new PropertyValueFactory<OLLFile, String>("fileActions")); fileActions.setCellFactory(new Callback<TableColumn<OllFile,String>, TableCell<OllFile, String>() { @Override public ListCell<String> call(ListView<ConsoleText<T>> param) { return new CellFactory(); } }); 

    Your factor

     public class CellFactory extends TableCell<OllFile, String> { public void CellFactory() { this.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { Desktop.open(new File(CellFactory.this.getItem())); } }); @Override public void updateItem(String item, boolean b) { if (b && item!= null) { setText(item.toString); } } 

    PS There may be syntax errors, because I wrote on my knee, and the rest - this idea.