package markharder.physicsdemos.demo.interfacing;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

/**
 * A simple java button
 *
 * @author Mark Harder
 * @version 1.0
 */
public class Button {
    private String name;
    private int index;

    public Button(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public void tick() {
    }

    public void draw(Graphics g) {
        g.setColor(Color.BLUE);
        g.fillRect(50, 50 + 60 * index, 300, 50);

        g.setColor(Color.WHITE);
        g.setFont(new Font("Times New Roman", Font.PLAIN, 30));
        g.drawString(name, 60, 90 + 60 * index);
    }
}


@@ -114,16 +114,93 @@
 raphics;
+%0Aimport java.awt.Rectangle;%0A%0Aimport markharder.physicsdemos.demo.input.Mouse;
 %0A%0A/**%0A *
@@ -287,16 +287,34 @@
  Button 
+extends Rectangle 
 %7B%0A    pr
@@ -354,16 +354,43 @@
 t index;
+%0A    private boolean hover;
 %0A%0A    pu
@@ -423,24 +423,69 @@
 nt index) %7B%0A
+        super(50, 50 + 60 * index, 300, 50);%0A
         this
@@ -522,24 +522,52 @@
 ex = index;%0A
+        this.hover = false;%0A
     %7D%0A%0A    p
@@ -594,46 +594,239 @@
     
-%7D%0A%0A    public void draw(Graphics g) %7B%0A
+    hover = false;%0A%0A        if (contains(Mouse.location)) %7B%0A            hover = true;%0A        %7D%0A    %7D%0A%0A    public void draw(Graphics g) %7B%0A        if (hover) %7B%0A            g.setColor(new Color(0, 0, 255, 200));%0A        %7D else %7B%0A    
     
@@ -849,24 +849,34 @@
 olor.BLUE);%0A
+        %7D%0A
         g.fi
@@ -886,36 +886,27 @@
 ect(
-50, 50 + 60 * index, 300, 50
+x, y, width, height
 );%0A%0A

add hover effect to Buttons