Hello I am trying to paint a bar graph using g.fillRect() to make each bar.
The bars will start at the grid height, y: 700, and fill upwards to y: 350 for example.
I am unable to set a negative x-height for my bar:
public void paint(Graphics g) {
for (Bar b : this.bars) {
g.fillRect(b.x_location,b.y_location,b.width,b.height * (-1));
}
}
This won't paint the bars.
Fix:
public void paint(Graphics g) {
for (Bar b : this.bars) {
g.fillRect(b.x_location,b.y_location - b.height,b.width,b.height);
}
}