[英]How to get ImageIcon path a String Java Jtable
if (j == model.getColumnCount() - 1) {
JLabel excelJL = (JLabel) model.getValueAt(i, j);
ImageIcon excelImageIcon = (ImageIcon) excelJL.getIcon();
System.out.println(excelImageIcon.);
}
我有一个图像存储在JLabel
并显示在JTable
行单元格中。
如何将图像路径作为字符串获取?
我能够检索图像并将其显示在另一个标签上,但我无法获取其路径。
C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg
JLabel excelJL = (JLabel) model.getValueAt(i, j);
ImageIcon excelImageIcon = (ImageIcon) excelJL.getIcon();
//Image Name Is Stored In ImageIcons Description First set it And Then Retrieve it
String excelImagePath = excelImageIcon.getDescription();
我设法使用 getDescription() 方法获取图像路径。 但是首先您需要在将图像添加到 jtable 单元格时设置描述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.