Hi Leute!
Mein erstelltes Applet habe ich nun in Html eingebunden.
Das Problem ist, das es mal ne Zeit lang flackert und dann wieder nicht.
Immer im Wechsel.
Wer kann helfen?Was ist falsch?
Gruß Ronn
Mein erstelltes Applet habe ich nun in Html eingebunden.
Das Problem ist, das es mal ne Zeit lang flackert und dann wieder nicht.
Immer im Wechsel.
Wer kann helfen?Was ist falsch?
Code:
import java.applet.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.ImageIcon;
public class Laufschrift extends Applet implements Runnable
{
int x, y, hoehe;
Thread my_thread;
String text,text2,text3,text4,text5,text6;
ImageIcon bild,bild2,backg;
public void init ( )
{
setSize(550,150);
bild2 = new ImageIcon(getClass().getResource("aaa.jpg"));
bild = new ImageIcon(getClass().getResource("bbb.jpg"));
backg = new ImageIcon(getClass().getResource("background.jpg"));
text = "aaa";
text2 = "bbb";
text3 = "ccc";
text4 = "ddd";
text5 = "eee";
text6 = "fff";
x = size().width / 2;
hoehe = size().height;
if (x > hoehe) y = hoehe;
}
public void start( )
{
my_thread = new Thread(this);
my_thread.start();
}
public void run()
{
while (true)
{
repaint();
y -= 10;
if (y < -90) y = hoehe;
try// Thread erfordert Ausnahme-Handler (try-catch-Klausel)
{
Thread.sleep(500);
}
catch (InterruptedException e) {
}
}
}
public void paint(Graphics g)
{
g.setColor(Color.blue);
backg.paintIcon(this,g,0,0);
bild2.paintIcon(this,g,50,75);
bild.paintIcon(this,g,50,10);
g.setColor(Color.red);
g.setFont(new Font("Comic Sans MS", Font.BOLD, 12));
g.drawString(text, x, y);
g.drawString(text2, x, y+15);
g.drawString(text3, x, y+30);
g.drawString(text4, x, y+45);
g.drawString(text5, x, y+60);
g.drawString(text6, x, y+75);
}
}
Gruß Ronn