if (j == model.getColumnCount() - 1) {
JLabel excelJL = (JLabel) model.getValueAt(i, j);
ImageIcon excelImageIcon = (ImageIcon) excelJL.getIcon();
System.out.println(excelImageIcon.);
}
I have an image stored in JLabel
and displayed in JTable
row cell.
How can I get the image path as a string?
I am able to retrieve the image and display it on another label but I am stuck at getting its path.
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();
I managed to get image path using getDescription() method. But first you need to set the description when adding image to jtable cell.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.