- import java.awt.*; //Pour le outils graphiques java
-
- public class Defil extends java.applet.Applet implements Runnable
- {
- Thread t;
- int Indic = 1, taille, x=60; //x sert à effectuer un décalage
- Graphics Mongraph; //déclaration d'un objet graphics
- Image Monimage; //objet image
-
- public void init()
- {
- Monimage = createImage(getSize().width, getSize().height); //image à la taille de l'applt
- Mongraph = Monimage.getGraphics(); //Pour éditer l'image
- }
-
- //Démarrage du Thread
- public void start()
- {
- if(t==null)
- {
- t = new Thread(this);
- t.start();
- }
- }
-
- //Arrêt du Thread
- public void stop()
- {
- if(t!=null)
- {
- Indic =0;
- t=null;
- }
- }
-
-
- public void run()
- {
- while (Indic == 1)
- {
- for(taille=20; taille<=80; taille++) //Agrandit la police
- {
- x-=2; //décale le message quand il s'agrandit
- attente(); //attendre entre chaque agrandissement
- }
- for(taille=80; taille>=20; taille--) //Réduit la police
- {
- attente(); //attente
- x+=2; //décale le message pendant la réduction
- }
- }
- }
-
- //Fonction d'attente
- public void attente()
- {
- repaint();
- try
- {
- Thread.sleep(10); //10 secondes de pause
- }
- catch(InterruptedException ie)
- {
- }
- }
-
- //Pour éviter le scintillement
- public void update(Graphics g)
- {
- paint(g);
- }
-
- public void paint(Graphics g)
- {
- Mongraph.setColor(Color.white); //Couleur de fond
- Mongraph.fillRect(0,0,400,200); //remplit le fond de l'applet
- Mongraph.setColor(Color.black); //Couleur du texte
- Mongraph.setFont(new Font("Arial",Font.BOLD,taille)); //Police + taille
- Mongraph.drawString("Bienvenue",x+55,100); //message
- g.drawImage(Monimage,0,0,this); //affichage de l'image
- }
- }
import java.awt.*; //Pour le outils graphiques java
public class Defil extends java.applet.Applet implements Runnable
{
Thread t;
int Indic = 1, taille, x=60; //x sert à effectuer un décalage
Graphics Mongraph; //déclaration d'un objet graphics
Image Monimage; //objet image
public void init()
{
Monimage = createImage(getSize().width, getSize().height); //image à la taille de l'applt
Mongraph = Monimage.getGraphics(); //Pour éditer l'image
}
//Démarrage du Thread
public void start()
{
if(t==null)
{
t = new Thread(this);
t.start();
}
}
//Arrêt du Thread
public void stop()
{
if(t!=null)
{
Indic =0;
t=null;
}
}
public void run()
{
while (Indic == 1)
{
for(taille=20; taille<=80; taille++) //Agrandit la police
{
x-=2; //décale le message quand il s'agrandit
attente(); //attendre entre chaque agrandissement
}
for(taille=80; taille>=20; taille--) //Réduit la police
{
attente(); //attente
x+=2; //décale le message pendant la réduction
}
}
}
//Fonction d'attente
public void attente()
{
repaint();
try
{
Thread.sleep(10); //10 secondes de pause
}
catch(InterruptedException ie)
{
}
}
//Pour éviter le scintillement
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
Mongraph.setColor(Color.white); //Couleur de fond
Mongraph.fillRect(0,0,400,200); //remplit le fond de l'applet
Mongraph.setColor(Color.black); //Couleur du texte
Mongraph.setFont(new Font("Arial",Font.BOLD,taille)); //Police + taille
Mongraph.drawString("Bienvenue",x+55,100); //message
g.drawImage(Monimage,0,0,this); //affichage de l'image
}
}