title: Graphics not drawing in paintComponent(Graphics)?
body: <p>I'm working on a custom Swing Component for my application, and I started drawing things with the <code>public void paintComponent(Graphics g)</code>. Everything works fine except for the fact that I can't draw any rectangles. I think the problem is with the <code>getX()</code> and <code>getY()</code> part, but I don't know that for sure. Here's my code:</p>
  
  <pre><code>@Override
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
  
      if (mouseEntered) {
          g.setColor(HIGHLIGHTED_COLOR);
      } else {
          g.setColor(BACKGROUND_COLOR);
      }
  
      g.fillRect(getX(), getY(), getWidth(), getHeight());
  
  
      //Draw rest of stuff (works fine)
  </code></pre>
  
  <p>The API says that it is supposed to be used like this: <code>g.fillRect(x, y, width, height)</code>, and that's what I'm doing.</p>
  
  <p>The rest of the drawing works perfectly, but I can't figure out why this isn't drawing. Any suggestions?</p>