import
java.awt.Container;
import
java.awt.Graphics;
import
java.awt.Image;
import
java.awt.Toolkit;
import
javax.swing.JFrame;
import
javax.swing.JPanel;
class
DemoPanel
extends
JPanel {
private
Image im1 = Toolkit.getDefaultToolkit().getImage(
"e:/123.jpg"
);
public
void
paintComponent(Graphics g) {
g.drawImage(im1,
0
,
0
,
null
);
}
}
public
class
DemoBackground
extends
JFrame {
public
DemoBackground() {
Container con =
this
.getContentPane();
DemoPanel my =
new
DemoPanel();
this
.setBounds(
200
,
100
,
400
,
300
);
con.add(my);
this
.setVisible(
true
);
this
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public
static
void
main(String[] args) {
new
DemoBackground();
}
}