整个applet用JPanel分成左右两个部分,我在左边设置了一幅图做为背景,但是后面添加的按钮和JLabel都被这幅图盖住了。
代码如下:
ImageIcon   background;
URLClassLoader urlLoader = (URLClassLoader)this.getClass().getClassLoader();
URL url;
String str = "cards/1.jpg";
url = urlLoader.findResource(str);
background   =   new   ImageIcon(url);//背景图片
JLabel label   =   new   JLabel(background);//把背景图片显示在一个标签里面  
label.setBounds(0,0,background.getIconWidth(),background.getIconHeight());  
setLayout(null);
leftPanel.add(label,new   Integer(Integer.MIN_VALUE));           
       label.setSize(background.getIconWidth(),background.getIconHeight());  
       label.setVisible(true);