i\'m trying to set a delay when a button is pressed to set an imageicon to a certain image then set another delay so that another image would be set, all of this by single click
You should try executing the code that sets the image in the event dispatch thread using InvokeLater.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
lblNewLabel.setIcon(and);
}
});
sleeep();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
lblNewLabel.setIcon(and);
}
});
don't add MouseListener to JButton, nor for mouseClicked()
, add ActionListener instead, btw all Mouse
and Key
events are implemented in JButton API and correctly
don't to use Thread.sleep(n);
you have an issue with Concurency in Swing, use Swing Timer instead,