日期:2014-05-20 浏览次数:20670 次
public class FrameDemo extends JFrame{
MyPanel mp;//为了设置背景图片,让界面更加美观
public FrameDemo()
{
super("传送文件窗口");
mp=new MyPanel();
this.add(mp);
this.setSize(400,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FrameDemo fd= new FrameDemo();
}
}
class MyPanel extends JPanel
{
//重写父类的方法设置背景
protected void paintComponent(Graphics g)
{
Image image=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/01.jpg"));
g.drawImage(image, 0, 0,this);
}
}