如何动态地在JTable中添加图像 [英] How to add image in JTable dynamically

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

问题描述

BufferedImage img = null;
        ImageIcon icon = null;
        try {
            img = ImageIO.read(new File("resources/" + imageString));           
        } catch (IOException e) {           
            e.printStackTrace();
        }
        img = ImageScaler.getScaledImage(img, 35, 35);
        icon = new ImageIcon(img);
table.setValueAt(icon, 1, 0);

这是我的代码。但是不显示图像。我需要一些帮助来找出我出错的地方。

this is my code. But image is not displayed. I need some help to find out where i went wrong.

推荐答案


  • 你必须阅读如何使用表格

    你可以把Icon或ImageIcon放到 JTable的Cell直接

    you can put Icon or ImageIcon to the JTable's Cell directly

    为了更好的帮助,请尽早使用 SSCCE 用JTable证明了你的问题

    for better help sooner edit your question with SSCCE demonstrated your issue with JTable

    这篇关于如何动态地在JTable中添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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