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 45 46 47 48 49 50 51 52 53 54
| import java.awt.*;
import java.applet.*;
public class Accueil extends Applet
{
private static final long serialVersionUID = 1L;
// Déclarations relatives à la résolution d'affichage
Dimension Ecran = Toolkit.getDefaultToolkit().getScreenSize();
int hauteur_écran = (int)Ecran.getHeight();
int largeur_écran = (int)Ecran.getWidth();
// Déclarations relatives aux images
Image fond_écran;
Image fond_écran_redim;
MediaTracker image_tracker;
// Déclarations diverses
String nom_fond_écran= "\\Images\\fond_ecran_accueil.jpg";
Font police_caractères;
int taille_caractères;
String libellé_status = "Essai de ma première JApplet...";
public void init()
{
// Initialisation des variables
image_tracker = new MediaTracker(this);
fond_écran = getImage(getCodeBase(),nom_fond_écran);
image_tracker.addImage(fond_écran, 0);
resize (largeur_écran,hauteur_écran);
taille_caractères = 20;
police_caractères = new Font("TimesRoman",police_caractères.BOLD,taille_caractères);
fond_écran_redim = fond_écran.getScaledInstance(largeur_écran, hauteur_écran, Image.SCALE_AREA_AVERAGING);
}
public void paint(Graphics display)
{
display.drawImage(fond_écran, 0, 0, this);
showStatus(libellé_status);
}
} |
Partager