首页javatooltipJava Swing - 如何从URL加载工具提示图像

Java Swing - 如何从URL加载工具提示图像

我们想知道如何从URL加载工具提示图像。
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Main {

  public static void main(String[] args) throws Exception {
    final String html = "<html><body>" + "<img src='"
        + "http://www.w3cschool.cn/style/download.png"
        + "' width=160 height=120> " + "<img src='"
        + "http://www.w3cschool.cn/style/download.png"
        + "' width=160 height=120>" + "<p>Message!";

    JLabel hover = new JLabel("Point at me!");
    hover.setToolTipText(html);
    JOptionPane.showMessageDialog(null, hover);

  }
}