title: Java Swing: paint under components of a JPanel?
body: <p>I have a JPanel that has a button in it. The location of the button is irrelevant. 
  The <code>paint(Graphics g)</code> code is:</p>
  
  <pre>
      @Override
      public void paint(Graphics g) {
          super.paint(g);
          /* drawing code */
      }
  </pre>    
  
  <p>If I wanted to fill the entire space of the panel with black rectangle, while also having the button in the panel, the filled in rectangle would simply cover everything up. So rather than having a button and then black all around the button, the entire panel is black.</p>
  
  <p><b>Is there any way to modify the panel, or the painting procedure, so that the components are drawn on top of the custom painting?</b></p>
  
  <p>I have tried to put <code>super.paint(g)</code> at the end of painting, like:</p>
  
  <pre>
      @Override
      public void paint(Graphics g) {
          /* drawing code */
          super.paint(g);
      }
  </pre> 
  
  <p>... thinking that it would do the custom painting first, and then simply put the components over it. However, if done like that, the custom painting disappears altogether and only the button shows up. That is, only a button and a white (default) background rather than the black rectangle.   </p>
  
  <p>Any ideas?<p>
  Thanks!
  <p>
  <b>Edit:</b> I want to clarify that the black rectangle is an example. I am aware that I could simply set the background color, but I am trying to ultimately be able to do any custom painting that I would like.</p>