class Button{ String name; boolean hover; boolean selected; int x = 0; int y = 0; int w = 0; int h = 0; Button(String name){ this.name = name; textFont(menufont); this.w = int(5+textWidth(name)+5); this.h = 20; } void update(int x, int y){ this.x = x; this.y = y; noStroke(); fill(190); if(hover) fill(220); if(selected) fill(190, 200, 220); textFont(menufont); rect(x, y, w, h); fill(0); textAlign(CENTER, CENTER); text(name, x, y, w, h); } void mouseMoved() { if(mouseX > x && mouseX < x+w && mouseY > y && mouseY < y+h){ hover = true; } else { hover = false; } } }