- import java.awt.*;
-
- public class Scroll2 extends java.applet.Applet implements Runnable
- {
- Thread t;
- int Indic = 1, y1;
- Graphics Gmem;
- Image ii;
-
- public void init()
- {
- ii = createImage(getSize().width,getSize().height); //création d'une image à la taille de l'applet
- Gmem = ii.getGraphics(); //Permet la création de l'image par des méthodes graphiques
- }
-
- public void start()
- {
- if(t==null)
- {
- t = new Thread(this);
- t.start();
- }
- }
-
- public void stop()
- {
- if(t!=null)
- {
- Indic =0;
- t=null;
- }
- }
-
- public void run()
- {
- while(Indic==1)
- {
- for(y1=-15;y1<120;y1++) //On augmente y1 pour faire bouger le texte de haut en bas
- {
- repaint();
- try
- {
- Thread.sleep(20);
- }
- catch(InterruptedException ie)
- {
- }
- }
- }
- }
-
- //Permet d'éviter le scintillement
- public void update(Graphics g)
- {
- paint(g);
- }
-
- public void paint(Graphics g)
- {
- Gmem.setColor(Color.black); //Couleur de fond
- Gmem.fillRect(0,0,260,100); //ramplissage du fond de l'applet
- Gmem.setColor(Color.yellow); //couleur du texte
- Gmem.setFont(new Font("Helvetica",Font.BOLD,20)); //Police+taille du texte
- Gmem.drawString("Voici un texte qui défile",15,y1); //Le texte + sa position
- g.drawImage(ii,0,0,this); //Affichage de l'image
- }
- }
import java.awt.*;
public class Scroll2 extends java.applet.Applet implements Runnable
{
Thread t;
int Indic = 1, y1;
Graphics Gmem;
Image ii;
public void init()
{
ii = createImage(getSize().width,getSize().height); //création d'une image à la taille de l'applet
Gmem = ii.getGraphics(); //Permet la création de l'image par des méthodes graphiques
}
public void start()
{
if(t==null)
{
t = new Thread(this);
t.start();
}
}
public void stop()
{
if(t!=null)
{
Indic =0;
t=null;
}
}
public void run()
{
while(Indic==1)
{
for(y1=-15;y1<120;y1++) //On augmente y1 pour faire bouger le texte de haut en bas
{
repaint();
try
{
Thread.sleep(20);
}
catch(InterruptedException ie)
{
}
}
}
}
//Permet d'éviter le scintillement
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
Gmem.setColor(Color.black); //Couleur de fond
Gmem.fillRect(0,0,260,100); //ramplissage du fond de l'applet
Gmem.setColor(Color.yellow); //couleur du texte
Gmem.setFont(new Font("Helvetica",Font.BOLD,20)); //Police+taille du texte
Gmem.drawString("Voici un texte qui défile",15,y1); //Le texte + sa position
g.drawImage(ii,0,0,this); //Affichage de l'image
}
}