title: Is it possible to overlay a JPanel on top of another?
body: <p>I am attempting to overlay a smaller panel (<code>sub</code>) over a larger panel (<code>parent</code>). The dimensions of sub are smaller than that of parent.</p>
  
  <pre><code>JPanel sub = new JPanel();
  JPanel parent = new CustomPanel();
  </code></pre>
  
  <p>I would like to override parent's <code>paintComponent</code> method to draw sub in the top left hand corner with an offset of 5 pixels from the top and left sides. It would look something like this:</p>
  
  <pre><code>class CustomPanel extends JPanel() {
  
      JPanel sub = null;
  
      public CustomPanel(JPanel sub) {
          this.sub = sub;
      }
  
      @Override
      public void paintComponent(Graphics g) {
          this.paintComponent(g);
          // TODO: Here is where I would call something like sub.paint();
          // However, I want sub to "start its paint" 5 pixels inside of
          // parent's dimensions. How do I specify this?
  </code></pre>
  
  <p>Is it possible to tell sub to paint itself at a specific location? Terrible idea?</p>