title: Overlapping panels
body: <p>I'm trying to make overlapping panels, but widgets below the 'topmost' panel somehow react to mouse events and repaint events and render above the top layer. For example, here I have bottom layer with lots some buttons and labels, and a top layer with up/down buttons, which is fully opaque for this test (gray background):
  <a href="https://i.stack.imgur.com/iBzdk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iBzdk.png" alt="enter image description here"></a>
  This uses the <code>OverlayLayout</code> manager to place panels on different Z levels. The buttons pop into view when hovering over them, and the labels on the right, which auto-update, also pop into view.</p>
  
  <p>SSCCE:</p>
  
  <pre><code>public class Temp extends JPanel {
      public static void main(String... args) {
          SwingUtilities.invokeLater(() -&gt; {
              JFrame f = new JFrame();
              f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  
              f.setContentPane(new Temp());
  
              f.setSize(500, 250);
              f.setLocationRelativeTo(null);
              f.setVisible(true);
          });
      }
  
      public Temp() {
          super(null);
          setLayout(new OverlayLayout(this));
  
          JButton bottom = new JButton("Bottom");
          JButton top    = new JButton("Top");
  
          bottom.setBounds(100, 50, 200, 100);
          top.setBounds(200, 100, 200, 100);
  
          // OverlayLayout adds components from top to bottom.
          add(new JPanel(null) {{
                  setBackground(new Color(175, 150, 125));
                  add(top);
              }});
          add(new JPanel(null) {{
                  add(bottom);
              }});
      }
  }
  </code></pre>
  
  <p>This is basically how I do it now. It looks like this after a bit of mouse hovering, but with hovering I can bring any of the two buttons above the other:
  <a href="https://i.stack.imgur.com/5rnZ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5rnZ7.png" alt="enter image description here"></a></p>
  
  <p>My question is, how can I fix this in the easiest way, or what is the standard way to handle this? Perhaps a Non-modal frame-less JDialog? One argument I have against the dialog is I rather not that the user uses keyboard shortcuts to move it around the screen.</p>