Questo è il codice con i Frame (ma allora non si parla più di Applet):
codice:
import java.awt.*;
import java.awt.event.*;
public class Scritta extends Frame {
private class Tempo extends Thread {
private Label lbl;
public Tempo(Label lbl) { this.lbl = lbl; }
public void run() {
try {
while( true ) {
Thread.sleep(1000);
lbl.setVisible( !scritta.isVisible() );
}
} catch (Exception e) {}
}
}
Label scritta;
Tempo t;
public Scritta() {
setLayout(null);
setBackground( Color.black );
scritta = new Label("Ciao");
scritta.setFont( new Font("Dialog", Font.BOLD, 18) );
scritta.setForeground( Color.white );
scritta.setBounds(100, 100, 200, 25);
add(scritta);
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent we) { System.exit(0); }
});
t = new Tempo(scritta);
t.start();
setSize(400, 400);
setTitle("Scritta lampeggiante");
show();
}
public static void main(String [] args) {
Scritta s = new Scritta();
}
}
Ciao.