簡體   English   中英

如何獲取 ImageIcon 路徑 String Java Jtable

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM