I wrote a little code to change the colours of a few buttons to stimulate a random sequence offlashing colours. i have set a timer to do this for me but i just dont know how to stop it
Heres my code
Timer timer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int buttons[] = new int[9];
for (int j = 0; j < buttons.length; j++) {
// System.out.println("times");
Component button = frame.getContentPane().getComponent(j);
int Red = new Random().nextInt(255 - 1) + 1;
int Green = new Random().nextInt(255 - 1) + 1;
int Blue = new Random().nextInt(255 - 1) + 1;
button.setBackground(new Color(Red, Green, Blue));
SwingUtilities.updateComponentTreeUI(button);
}
}// }
}); timer.start();