notes on Liang(2009), p.964
use a thread to control animations
import javax.swing.*;
public class FlashingText extends JApplet implements Runnable
{
private JLabel jlblText = new JLabel("DMC Welcome", JLabel.CENTER);
public FlashingText()
{
add(jlblText);
new Thread(this).start();
}
public void run()
{
try
{
while(true)
{
if (jlblText.getText() == null)
jlblText.setText("DMC Welcome");
else
jlblText.setText(null);
Thread.sleep(300); // static
} // end while
}
catch(InterruptedException e)
{
}
}
}
Keine Kommentare:
Kommentar veröffentlichen