我有两个问题:
JButton时单击到更亮版本的img1时更改一个setIcon(),但是在运行期间没有任何变化。
私有JButton btnImg1 =新JButton("");ImageIcon img1 =新ImageIcon (“C:\User\vide\Desktop\img1.png”);ImageIcon img1_b =新JButton尝试{ btnImg1.setIcon(img1);Thread.sleep(2000年);btnImg1.setIcon(img1_b);}int Lists来保存输入和随机序列,这是动态大小的原因:
列表seqAlea =新的ArrayList();列表seqInsere =新的ArrayList();int placar = 0;geraNumero =新的ArrayList();公开的comecaJogo(){ for(int i= 0;i< 3;i++){ int数字= geraNumero.nextInt(4) + 1;seqAlea.add(i,数字);}}有更好的方法吗?
发布于 2015-11-03 12:45:09
首先,不要在主线程中使用睡眠,如果您不打算阻止它,这将使您的应用程序等待睡眠结束,从而“阻塞”您的主线程。
https://stackoverflow.com/questions/33498455
复制相似问题