Image in JavaFX ListView

前端 未结 2 1386
春和景丽
春和景丽 2021-01-14 15:28

Is there anyway to add an image to a JavaFX ListView?

This is how I am currently setting the list view items.

private ListView friends;         


        
2条回答
  •  一生所求
    2021-01-14 16:10

    remember to refresh or load your Listview with myListViewWithPath.setItems(myObserverFilledWithImages);

    @FXML
        private void browseButton(ActionEvent event) throws Exception {
            System.out.println("browseButton");
            DirectoryChooser chooser = new DirectoryChooser();
            File file = chooser.showDialog(myStage);
            file = new File("E:\\FOLDER\\Imagen_File");
    
            if (file != null) {
                directoryField.setText(file.toString());
                oImage.setAll(load(file.toPath()));
            }
            imageFilesList.setItems(oImage); //this one load or refresh the ListView
        }
    

提交回复
热议问题