source:
lost-haven/gamegui/ProgressBar.java@
4d8825f
Last change on this file since 4d8825f was 8edd04e, checked in by , 5 years ago | |
---|---|
|
|
File size: 898 bytes |
Rev | Line | |
---|---|---|
[8edd04e] | 1 | package gamegui; |
2 | ||
3 | import java.awt.Color; | |
4 | import java.awt.Graphics; | |
5 | ||
6 | public class ProgressBar extends Member { | |
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 | } | |
41 | } |
Note:
See TracBrowser
for help on using the repository browser.