Java设置软件图标即窗口上角图标
Java设置窗口图标
import java.awt.Frame;
import java.awt.Image;
import java.awt.Toolkit;
实现代码:
public class TestMain {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// Create frame
String title = "Frame Title";
Frame frame = new Frame(title);
// Set icon
Image icon = Toolkit.getDefaultToolkit().getImage("D:\\image.jpg");
frame.setIconImage(icon);
frame.setSize(100, 100);
frame.setVisible(true);
}
}
import java.awt.Image;
import java.awt.Toolkit;
实现代码:
public class TestMain {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
// Create frame
String title = "Frame Title";
Frame frame = new Frame(title);
// Set icon
Image icon = Toolkit.getDefaultToolkit().getImage("D:\\image.jpg");
frame.setIconImage(icon);
frame.setSize(100, 100);
frame.setVisible(true);
}
}