import java.awt.*;
import javax.swing.*;
public class Test extends JPanel {
private static void createAndShowGUI() {
JFrame frame = new JFrame("Change Icon");
Image icon = new ImageIcon("image.png").getImage();
frame.setIconImage(icon); // 关键之处在这里
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 500);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Test.createAndShowGUI();
}
});
}
}
在标题栏上显示自己的图标
最新推荐文章于 2021-02-13 00:49:33 发布