rupa
rupa

Reputation: 241

How to display the images in listview

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.

Upvotes: 2

Views: 6442

Answers (1)

Alexander Kirov
Alexander Kirov

Reputation: 3654

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.

Upvotes: 3

Related Questions