Changeset 8edd04e in lost-haven for gamegui/Member.java
- Timestamp:
- Jun 7, 2020, 3:04:32 PM (5 years ago)
- Branches:
- master
- Children:
- a49176d
- Parents:
- 155577b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gamegui/Member.java
r155577b r8edd04e 1 1 package gamegui; 2 2 3 import java.awt. *;4 import java.awt.event. *;3 import java.awt.Graphics; 4 import java.awt.event.MouseEvent; 5 5 6 6 public class Member { 7 private String name;8 private int x;9 private int y;10 private int width;11 private int height;12 private ScrollBar scrollbar;13 14 public Member(String newName, int newX, int newY, int newWidth, int newHeight) {15 name = newName;16 x = newX;17 y = newY;18 width = newWidth;19 height = newHeight;20 }21 22 public void draw(Graphics g) {23 7 24 } 25 26 public boolean handleEvent(MouseEvent e) { 27 return false; 28 } 29 30 public boolean isClicked(int xCoord, int yCoord) { 31 return x <= xCoord && xCoord <= x+width && y <= yCoord && yCoord <= y+height; 32 } 33 34 public void clear() { 35 36 } 37 38 public String getName() { 39 return name; 40 } 41 42 public int getX() { 43 return x; 44 } 45 46 public int getY() { 47 return y; 48 } 49 50 public int getWidth() { 51 return width; 52 } 53 54 public int getHeight() { 55 return height; 56 } 57 58 public ScrollBar getScrollBar() { 59 return scrollbar; 60 } 8 private String name; 9 private int x; 10 private int y; 11 private int width; 12 private int height; 13 private ScrollBar scrollbar; 61 14 62 public void addScrollBar(ScrollBar newBar) { 63 newBar.offset(x, y); 64 scrollbar = newBar; 65 } 66 67 protected void offset(int xOffset, int yOffset) { 68 x += xOffset; 69 y += yOffset; 70 71 if(scrollbar != null) 72 scrollbar.offset(xOffset, yOffset); 73 } 15 public Member(String newName, int newX, int newY, int newWidth, int newHeight) { 16 this.name = newName; 17 this.x = newX; 18 this.y = newY; 19 this.width = newWidth; 20 this.height = newHeight; 21 } 22 23 public void draw(Graphics g) {} 24 25 public boolean handleEvent(MouseEvent e) { 26 return false; 27 } 28 29 public boolean isClicked(int xCoord, int yCoord) { 30 return (this.x <= xCoord && xCoord <= this.x + this.width && this.y <= yCoord && yCoord <= this.y + this.height); 31 } 32 33 public void clear() { 34 } 35 36 public String getName() { 37 return this.name; 38 } 39 40 public int getX() { 41 return this.x; 42 } 43 44 public int getY() { 45 return this.y; 46 } 47 48 public int getWidth() { 49 return this.width; 50 } 51 52 public int getHeight() { 53 return this.height; 54 } 55 56 public ScrollBar getScrollBar() { 57 return this.scrollbar; 58 } 59 60 public void setWidth(int width) { 61 this.width = width; 62 } 63 64 public void setHeight(int height) { 65 this.height = height; 66 } 67 68 public void addScrollBar(ScrollBar newBar) { 69 newBar.offset(this.x, this.y); 70 this.scrollbar = newBar; 71 } 72 73 protected void offset(int xOffset, int yOffset) { 74 this.x += xOffset; 75 this.y += yOffset; 76 if (this.scrollbar != null) { 77 this.scrollbar.offset(xOffset, yOffset); 78 } 79 } 74 80 }
Note:
See TracChangeset
for help on using the changeset viewer.