首页javajoptionpaneJava Swing - 如何安装JOptionPane的自定义图标

Java Swing - 如何安装JOptionPane的自定义图标

我们想知道如何安装JOptionPane的自定义图标。
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

public class Main {
  public static void main(String[] args) throws Exception {

    ImageIcon icon = new ImageIcon(new URL(
        "http://www.w3cschool.cn/style/download.png"));

    UIManager.put("OptionPane.informationIcon", icon);

    JOptionPane.showMessageDialog(null, "Hello!");
  }
}