Essentially the question says it all. I have a program where I initiate the canvas (JApplet
) and set its size to not the default values. I wait for the timer to end and then it resizes. I don't want a delay, I aiming for instant.
How do I initiate the applet with a different size or background color on its first instance?
import javax.swing.JApplet;
import java.awt.MouseInfo;
import java.awt.Graphics;
public class GameBoard extends JApplet {
public void paint(Graphics canvas) {
setSize(100,450);
// TODO Auto-generated method stub
//int
int i = 0;
while(i < 2){
waiting(1.0);
i++;
}
}
public static void waiting (double n){
long t0, t1;
t0 = System.currentTimeMillis();
do{
t1 = System.currentTimeMillis();
}
while ((t1 - t0) < (n * 1000));
}
}