Java Reference
In-Depth Information
try {
OK = new java.net.URL(getCodeBase().toString() + “images/ok.gif”);
} catch (java.net.MalformedURLException ex) {
System.out.println(ex.getMessage());
System.exit(1);
}
scene3d.OK = new TextureLoader(OK, this).getTexture();
}
d.9 defInInG countdoWn tImer obJect for GIvInG
remaInInG tIme for maIn applet
class timerField extends JTextField implements Runnable
{
private boolean running = false;
private Thread timerThread;
public timerField(int col)
{
setColumns(col);
setEditable(false);
//setBackground(Color.white);
//setBounds(1, 1, 20, 20);
running = true;
timerThread = new Thread(this);
timerThread.start();
}
public void run()
{
int min, sec;
String minute, second;
long startTime, currentTime;
startTime = System.currentTimeMillis();
while (running)
{
currentTime = System.currentTimeMillis();
min = Math.round((currentTime - startTime) / 60000L);
sec = Math.round((currentTime - startTime - min * 60000L) / 1000);
minute = Integer.toString(min);
second = Integer.toString(sec);
if (minute.length() < 2) {
minute = “0” + minute;
}
if (second.length() < 2) {
second = “0” + second;
}
setText(“”+minute+”:”+second);
Search WWH ::




Custom Search