My goal is creating a function that waits half second, set the jbutton's background to red for one second, and after this second the jbutton will return to normal. Cant make this work.. This is my Function
private void paint(final int num){
Timer timer = new Timer(500, new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (num == 1){
btn.setBackground(Color.black);
}
}
});
timer.start();
}