【发布时间】:2013-10-25 12:20:45
【问题描述】:
我的函数绘制三个随机数,并根据这个数字为 JLabel 设置适当的图标(一、二、三)。我需要在 2 秒后更改此图标。
public void random() {
Random rand = new Random();
num1 = rand.nextInt(3);
num2 = rand.nextInt(3);
num3 = rand.nextInt(3);
if (num1==0){
one.setIcon(icon7);
}
if (num1==1){
one.setIcon(icon8);
}
if (num1==2){
one.setIcon(icon9);
}
if (num2==0){
two.setIcon(icon7);
}
if (num2==1){
two.setIcon(icon8);
}
if (num2==2){
two.setIcon(icon9);
}
if (num3==0){
three.setIcon(icon7);
}
if (num3==1){
three.setIcon(icon8);
}
if (num3==2){
three.setIcon(icon9);
}}
2 秒后,我想像这样更改图标:
one.setIcon(icon10);
two.setIcon(icon10);
three.setIcon(icon10);
我不知道该怎么做,请帮帮我:)
【问题讨论】:
标签: java multithreading random jlabel