Guest User

Untitled

a guest
Sep 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.ActionEvent;
  3. import java.awt.event.ActionListener;
  4.  
  5. public class Box implements ActionListener{
  6.  
  7. private int upperLeftX;
  8. private int upperLeftY;
  9. private int height;
  10. private int width;
  11. private Color boxColor;
  12. private int button;
  13.  
  14.  
  15. public Box(int upperX, int upperY, int h, int w, Color myColor, Grid grid){
  16. this.upperLeftX = upperX;
  17. this.upperLeftY = upperY;
  18. this.height = h;
  19. this.width = w;
  20. this.boxColor = myColor;
  21.  
  22. button = new Button();
  23. button.setBounds(upperX,upperY,w,h/2);
  24. grid.add(button);
  25. button.addActionListener(this);
  26. button.addActionListener(grid);
  27.  
  28. }
  29.  
  30.  
  31. public void display(Graphics g){
  32. g.setColor(boxColor);
  33. g.fillRect(upperLeftX,upperLeftY,width,height);
  34. }
  35.  
  36.  
  37.  
  38. public int getUpperLeftX() {
  39. return upperLeftX;
  40. }
  41.  
  42. public void setUpperLeftX(int upperLeftX) {
  43. this.upperLeftX = upperLeftX;
  44. }
  45.  
  46. public int getUpperLeftY() {
  47. return upperLeftY;
  48. }
  49.  
  50. public void setUpperLeftY(int upperLeftY) {
  51. this.upperLeftY = upperLeftY;
  52. }
  53.  
  54. public int getHeight() {
  55. return height;
  56. }
  57.  
  58. public void setHeight(int height) {
  59. this.height = height;
  60. }
  61.  
  62. public int getWidth() {
  63. return width;
  64. }
  65.  
  66. public void setWidth(int width) {
  67. this.width = width;
  68. }
  69.  
  70. public Color getBoxColor() {
  71. return boxColor;
  72. }
  73.  
  74. public void setBoxColor(Color boxColor) {
  75. this.boxColor = boxColor;
  76. }
  77.  
  78.  
  79.  
  80. public void actionPerformed(ActionEvent arg0) {
  81.  
  82.  
  83. boxColor = boxColor.brighter(); }
  84.  
  85.  
  86.  
  87. }
Add Comment
Please, Sign In to add comment