I'm trying to make the buttons highlight (by changing color) when i am hovering above them with my mouse. this is my code;
import javax.swing.JOptionPane;
final int BUTTON_WIDTH = 100;
final int BUTTON_HEIGHT = 50;
int buttonX = 0;
int COLOR = 150;
void setup() {
size(800, 400);
}
void draw() {
for (int i=0; i<=8; i++) {
drawButtons();
buttonX = buttonX+BUTTON_WIDTH;
}
}
void drawButtons() {
strokeWeight(2);
fill(0, COLOR, COLOR);
rect(buttonX, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
}
I thought it would work if i add this ;
if(mouseX<BUTTON_WIDTH && mouseY<BUTTON_HEIGHT){
COLOR = 255;
}
It does not work though, i am trying to make the button highlight when the mouse is over it and the other buttons would remain unchanged.