import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Toolkit;
import java.awt.Image;
public class Login
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
JFrame jf = new JFrame("登陆");
JPanel jp=new JPanel();
Toolkit toolkit = jf.getToolkit();
//Image image = toolkit.getImage("1.jpg");
Image image = toolkit.getImage("2.png");
jf.setIconImage(image);
jf.add(jp);
jf.setSize(200,100);
jp.setBackground(Color.cyan);
jf.setLocation(500, 300);
jf.setVisible(true);
}
}
我的图片目录在D:\Program Files\eclipse\qun\src
为什么显示不出来呢
------解决方案--------------------
Image image = toolkit.getImage("src/2.png");