D
defcon8
Hello, I have just started learning swing and I have tried to make a
small programme that shows a number that goes up by 1 every increment,
I am trying to figure out how I can make it sleep and so on. Could
anyone correct my code?
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Grapho {
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(400,400);
JLabel label = new JLabel();
int i = 0;
while(i != 10) {
label.setText(Integer.toString(i));
Thread.sleep(1);
frame.getContentPane().add(label);
frame.setvisible(true);
i++;
}
}
}
small programme that shows a number that goes up by 1 every increment,
I am trying to figure out how I can make it sleep and so on. Could
anyone correct my code?
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Grapho {
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setSize(400,400);
JLabel label = new JLabel();
int i = 0;
while(i != 10) {
label.setText(Integer.toString(i));
Thread.sleep(1);
frame.getContentPane().add(label);
frame.setvisible(true);
i++;
}
}
}