gpt4 book ai didi

java - JTable中添加Image时显示的字符串路径

转载 作者:行者123 更新时间:2023-12-01 16:33:11 25 4
gpt4 key购买 nike

我尝试使用 setValueAt 添加图像,但问题是它打印字符串并且不加载图像。对此有任何帮助。代码如下

int selectedColumn = table1.getSelectedColumn();
int selectedRow = table1.getSelectedRow();
ImageIcon addIcon = new ImageIcon("c:\\onion.png");
table1.getModel().setValueAt(addIcon, selectedRow, electedColumn);

最佳答案

您需要create a table model它为其 getColumnClass 返回 Icon.class方法。

关于java - JTable中添加Image时显示的字符串路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12346152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com