Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のコードを使用して、ローカル ドライブの画像をツールチップとして使用していますが、画像が表示されません。
String path = "C:/images/A.png"; labelIMG.setToolTipText("<html><img src='"+path+"'></html>");
これを回避するには、事前に感謝します!
ツールチップのレンダリングは、ファイル参照ではなく URL を想定しています...
代わりにこのようなことを試してください。
String path = "C:/images/A.png"; File file = new File(path); labelIMG.setToolTipText("<html><img src='"+file.toURI().toURL()+"'></html>");
もちろん、単純なString.file:///c:/images/A.png
String
file:///c:/images/A.png