1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
import javax.swing.*
import java.awt.*;
//La classe d'entrée
public class App()
{
public App()
{
LeFrame frame=new JFrame();
frame.show();
}
static public void main(String args[])
{
new App();
}
}
//La classe LeFrame
public class LeFrame extends JFrame
{
LePanel panel=new LePanel();
public LeFrame()
{
setVisible(true);
setSize(400,400);
getContentPane.add(panel);
}
}
//La classe du panel
public class LePanel extends JPanel
{
ImageIcon im;
public LePanel()
{
im=new ImageIcon("image.gif");
}
public void paint(Graphics g)
{
super.paint(g);
g.drawImage(im.getImage(),0,0,im.getIconWidth,im.getIconHeight(),this);
}
} |