日期:2014-05-20 浏览次数:20742 次
//添加兔子
public void setIcon(MainFrame frame)
{
//从兔子图片的路径得到兔子图片对象
ImageIcon icon1 = new ImageIcon("/afs/user/Desktop/location/Rabbit.JPG");
image1 = icon1.getImage();
//得到背景图像的画笔,背景图像画在主frame的label上
Graphics2D g=(Graphics2D)frame.getLabel().getGraphics();
//画兔子
g.drawImage(image1, 400, 400, frame.getLabel());
}
JLabel iconLabel = new JLabel();
ImageIcon icon1 = new ImageIcon("/afs/user/Desktop/location/Rabbit.JPG");
iconLabel.setIcon(icon1)
frame.getContentPanel().add(iconLabel, BorderLayout.center);