I am attempting to add a "health bar" to a game in java. I have a painted background and am wondering how I would draw a smaller rectangle on top of that. Do I need to create a new Graphics member variable? All the examples I have looked at require me to create an entire class and are using somewhat foreign java utilities (at least to me). In my class that extends JPanel, I have the function:
public void paintComponent(Graphics g)
{ 
   // This draws the background
   g.setColor(Color.RED);
   g.fillRect(0, 0, this.getWidth(), this.getHeight());
   // This draws the health bar
   ...
Is there an easy way to do this?