How to display the images in listview

老子叫甜甜 提交于 2019-12-11 03:30:08

问题


I am working with JavaFX2.0.I need to show the thumbnail images in listview.I am writing the code as below.

ObservableList<BufferedImage> imageList = FXCollections.observableArrayList();
        try {
            for (int i = 1; i <= pdf.getPageCount(); i++) {
                BufferedImage pageImage = pdf.getPageAsImage(i);
                imageList.add(pageImage);
            } catch (PdfException e) {
            _logger.error("Error :" + e.getMessage());
            }
           thumbnailsList.setItems(imageList);

Here thumbnailsList is the fx:id of the listview.But if i use this code i am getting image object and not an image.Can any one tell me that how can i get the image in listview.

Thank You.


回答1:


You could use a sample from

http://docs.oracle.com/javafx/2/ui_controls/list-view.htm

which is called "Example 11-4 Creating a Cell Factory".

You have to set custom cell factory. And instead of Rectangle, put an ImageView there.



来源:https://stackoverflow.com/questions/14950341/how-to-display-the-images-in-listview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!