import javax.swing.*;
public class IS extends JFrame {
IS(){
JPanel p=new JPanel();
JLabel l=new JLabel();
Icon icon=new ImageIcon("D:\\a.jpg"); //在此直接创建对象
l.setIcon(icon);
l.setBounds(0, 0, icon.getIconWidth(),icon.getIconHeight());
p.add(l,new Integer(Integer.MIN_VALUE));
getContentPane().add(p);
pack(); //窗口适应组件大小
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //用来关闭窗口的
setVisible(true);
}
public static void main(String[] a){
new IS();
}
}
//代码已运行过