super("《《 日 历 》》");

jlb=new JLabel(new ImageIcon("bg.jpg"));
this.getLayeredPane().add(jlb);
((JPanel)getContentPane()).setOpaque(false);
this.getContentPane().setLayout(new BorderLayout());
st=new ShowTimePanel();
tc=new TextCalendar();
tc.setCalendar();

this.getContentPane().add(tc,"Center");
this.getContentPane().add(st,"South");
setVisible(true);
setSize(400,250);

解决方案 »

  1.   

    this.setBackground("图片.jpg");这样应该可以的
      

  2.   

    不行啊,里面参数是Color类型的不是Image类型
      

  3.   

    你可以在这个Frame上添加一个Label,然后用Label引入一个Image,Image对象可以引入一个图片。
      

  4.   

    import javax.swing.*;
    import java.awt.Graphics;
    public class BackImg extends JFrame{
    public BackImg(){
    super("背景图片");
    this.setSize(500,400);
    JPanel p=new JPanel(){
    public void paintComponent(Graphics g){
    ImageIcon img=new ImageIcon("F:/a.jpg");
    g.drawImage(img.getImage(),0,0,getSize().width,getSize().height,null);
    }

    };
    p.add(new JButton("背景图片"));
    p.add(new JLabel("背景图片"));
    this.setContentPane(p);
    setVisible(true) ;
    }
    public static void main (String[] args) {
    new BackImg();
    }


    }
      

  5.   

    前提:图片bg.jpg与类放在同一个source文件夹下面。
    将jlb=new JLabel(new ImageIcon("bg.jpg")); 代码改为
    ImageIcon image = new ImageIcon(this.getClass().getResource("bg.jpg");
    jlb=new JLabel(image); 如果图片是单独放在一个文件夹可以再调整一下路径,路径的开始不用加"/"
      

  6.   

    而5楼的this.setContentPane(p);决定了图片大小,add(p)的话会很小
    其实重写这个方法就行
    public void paint(Graphics g){ 
    ImageIcon img=new ImageIcon("F:/a.jpg");
    g.drawImage(img.getImage(),0,0,getSize().width,getSize().height,null); 
    }