Changeset 8edd04e in lost-haven for gamegui/ProgressBar.java
- Timestamp:
- Jun 7, 2020, 3:04:32 PM (4 years ago)
- Branches:
- master
- Children:
- a49176d
- Parents:
- 155577b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gamegui/ProgressBar.java
r155577b r8edd04e 5 5 6 6 public class ProgressBar extends Member { 7 private int max; 8 private int current; 9 10 public ProgressBar(String newName, int newX, int newY, int newWidth, int newHeight) { 11 super(newName, newX, newY, newWidth, newHeight); 12 13 max = 1; 14 current = 0; 15 } 16 17 public int getMax() { 18 return max; 19 } 20 21 public int getCurrent() { 22 return current; 23 } 24 25 public void setMax(int max) { 26 this.max = max; 27 } 28 29 public void setCurrent(int current) { 30 this.current = current; 31 } 32 33 public void draw(Graphics g) { 34 g.setColor(Color.black); 35 g.fillRect(getX(), getY(), getWidth(), getHeight()); 36 37 g.setColor(Color.blue); 38 g.fillRect(getX(), getY(), getWidth()*current/max, getHeight()); 39 g.setColor(Color.red); 40 g.drawRect(getX(), getY(), getWidth(), getHeight()); 41 } 7 8 private int max; 9 private int current; 10 11 public ProgressBar(String newName, int newX, int newY, int newWidth, int newHeight) { 12 super(newName, newX, newY, newWidth, newHeight); 13 this.max = 1; 14 this.current = 0; 15 } 16 17 public int getMax() { 18 return this.max; 19 } 20 21 public int getCurrent() { 22 return this.current; 23 } 24 25 public void setMax(int max) { 26 this.max = max; 27 } 28 29 public void setCurrent(int current) { 30 this.current = current; 31 } 32 33 public void draw(Graphics g) { 34 g.setColor(Color.black); 35 g.fillRect(getX(), getY(), getWidth(), getHeight()); 36 g.setColor(Color.blue); 37 g.fillRect(getX(), getY(), getWidth() * this.current / this.max, getHeight()); 38 g.setColor(Color.red); 39 g.drawRect(getX(), getY(), getWidth(), getHeight()); 40 } 42 41 }
Note:
See TracChangeset
for help on using the changeset viewer.