参考:http://blog.csdn.net/newflypig/archive/2007/10/30/1857883.aspx 部分内容如下:2.再看在Application中利用swing包,构建带有图片的窗体代码: JFrame jf=new JFrame(); Image m=new Image(); m=Toolkit.getDefaultToolkit().getImage("top.jpg");//get the image you want JLabel lb=new JLabel(); lb.setIcon(new ImageIcon(m)); //add a label contains the image which have to change to ImageIcon; jf.getContentPane().add(lb); //add the label to our Frame; 当然,也可以自己写一个窗口类,然后重载其中的paint方法代码: Image m=new Image(); m=Toolkit.getDefaultToolkit().getImage("top.jpg");public void paint(Graphics g)...{ g.drawImage(m,insets.left,insets.top,this); }
部分内容如下:2.再看在Application中利用swing包,构建带有图片的窗体代码:
JFrame jf=new JFrame();
Image m=new Image();
m=Toolkit.getDefaultToolkit().getImage("top.jpg");//get the image you want
JLabel lb=new JLabel();
lb.setIcon(new ImageIcon(m)); //add a label contains the image which have to change to ImageIcon;
jf.getContentPane().add(lb); //add the label to our Frame; 当然,也可以自己写一个窗口类,然后重载其中的paint方法代码:
Image m=new Image();
m=Toolkit.getDefaultToolkit().getImage("top.jpg");public void paint(Graphics g)...{
g.drawImage(m,insets.left,insets.top,this);
}