Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class Box implements ActionListener{
- private int upperLeftX;
- private int upperLeftY;
- private int height;
- private int width;
- private Color boxColor;
- private int button;
- public Box(int upperX, int upperY, int h, int w, Color myColor, Grid grid){
- this.upperLeftX = upperX;
- this.upperLeftY = upperY;
- this.height = h;
- this.width = w;
- this.boxColor = myColor;
- button = new Button();
- button.setBounds(upperX,upperY,w,h/2);
- grid.add(button);
- button.addActionListener(this);
- button.addActionListener(grid);
- }
- public void display(Graphics g){
- g.setColor(boxColor);
- g.fillRect(upperLeftX,upperLeftY,width,height);
- }
- public int getUpperLeftX() {
- return upperLeftX;
- }
- public void setUpperLeftX(int upperLeftX) {
- this.upperLeftX = upperLeftX;
- }
- public int getUpperLeftY() {
- return upperLeftY;
- }
- public void setUpperLeftY(int upperLeftY) {
- this.upperLeftY = upperLeftY;
- }
- public int getHeight() {
- return height;
- }
- public void setHeight(int height) {
- this.height = height;
- }
- public int getWidth() {
- return width;
- }
- public void setWidth(int width) {
- this.width = width;
- }
- public Color getBoxColor() {
- return boxColor;
- }
- public void setBoxColor(Color boxColor) {
- this.boxColor = boxColor;
- }
- public void actionPerformed(ActionEvent arg0) {
- boxColor = boxColor.brighter(); }
- }
Add Comment
Please, Sign In to add comment