如何在列表视图中显示图像 [英] How to display the images in listview

查看:74
本文介绍了如何在列表视图中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaFX2.0.我需要在列表视图中显示缩略图.我正在编写如下代码.

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);

这里thumbnailsList是listview的fx:id.但是,如果我使用此代码,我得到的是图像对象而不是图像.有人可以告诉我如何在listview中获得图像.

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.

谢谢.

推荐答案

您可以使用以下示例:

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

称为示例11-4创建单元工厂".

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

您必须设置自定义单元工厂.然后在其中放置ImageView代替Rectangle.

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

这篇关于如何在列表视图中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆