Problem with properly displaying color( with alpha) of JButton
-
For my Java class, I have to implement a computer version of the game of Simon (with the color panel sequence). In the program, I have a subclass of JButton, SimonButton. I want SimonButton to display a dimmed color. The SimonButtons are in a JPanel, which is in a JFrame. I do this by giving it a low alpha as such:
public void setColor(Color color) {
this.setBackground(new Color(color.getRed(),
color.getGreen(),
color.getBlue(),
alpha));
}with alpha = 20. The program starts off working well, but every time I move the mouse over a button, the color becomes brighter. I'm assuming that the SimonButtons are just being drawn over each other, thus making the colors cumulative. How do I make it so that the buttons get completely redrawn instead of drawing over top of them?