教师的工作环境特点:我想要在JFrame的上面一部分添加图片,但是图片显示不出来,请大家帮忙看一下

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 04:08:22
相关代码是这样的:
public class Chat extends JFrame{
private Container container;
private JLabel imageLabel;
private JPanel imagePanel;
public Chat(){
container=getContentPane();
ImageIcon ii = new ImageIcon("images/back.gif");
imageLabel=new JLabel(ii);
imagePanel=new JPanel();
container.add(imagePanel);
container.setLayout(new FlowLayout());
setSize(300,200);
show();
} public static void main(String [] args){
Chat chat=new Chat();
chat.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
}
}
请问代码错在哪里啊?