我想在actionPerfromed()
arr[1]=bot and try{...
内等待
我尝试使用swing.timer
和Thread.sleep()
,但它们无法正常工作。如果你需要,我会附上整个程序。
感谢您的帮助。
class pulsarBoton implements ActionListener,Serializable{
@Override
public void actionPerformed(ActionEvent e) {
JButton bot=(JButton)e.getSource();
if (arrBot[0]==null) {
arrBot[0]=bot;
arrBot[0].setIcon(new ImageIcon(arr.get(Integer.valueOf(bot.getName()))+".jpg"));//como puedo quitar el texto del boton pero referenciarlo al array??
}else{
bot.setIcon(new ImageIcon(arr.get(Integer.valueOf(bot.getName()))+".jpg"));
arrBot[1]=bot;
//JOptionPane.showMessageDialog(null, "Continuar");
try {
//espera(4000);// --> IT DOES NOT WORK AS I WANT
comprobar(arrBot);
} catch (IOException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
我尝试了这个,但它不起作用。是不是错了?
class pulsarBoton implements ActionListener,Serializable{
@Override
public void actionPerformed(ActionEvent e) {
JButton bot=(JButton)e.getSource();
if (arrBot[0]==null) {
arrBot[0]=bot;
arrBot[0].setIcon(new ImageIcon(arr.get(Integer.valueOf(bot.getName()))+".jpg"));//como puedo quitar el texto del boton pero referenciarlo al array??
}else{
bot.setIcon(new ImageIcon(arr.get(Integer.valueOf(bot.getName()))+".jpg"));
arrBot[1]=bot;
//JOptionPane.showMessageDialog(null, "Continuar");
//espera(4000);// --> IT DOES NOT WORK AS I WANT
try {
Timer tiempo=new Timer(3000, new timerPerformed());
tiempo.start();
comprobar(arrBot);
} catch (IOException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
class timerPerformed implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("A");
}
}