title: Swing: Showing a transparent Panel hovering over another Panel
body: <p>I want to show a textArea showing some text (will show log lines) , and have an animated gif hoovering above it. I tried the solution described <a href="https://stackoverflow.com/questions/852631/java-swing-how-to-show-a-panel-on-top-of-another-panel">here</a> , but all I get is a grey screen. Hints?</p>
  
  <pre><code>public class TestLayeredPanes {
  
      private JFrame frame = new JFrame();
      private JLayeredPane lpane = new JLayeredPane();
  
      public TestLayeredPanes() {
          frame.setPreferredSize(new Dimension(600, 400));
          frame.setLayout(new BorderLayout());
          frame.add(lpane, BorderLayout.CENTER);
  
          //Build the animated icon
          JLabel buildingIcon = new JLabel();
          buildingIcon.setIcon(new ImageIcon(this.getClass().getResource(
                  "/com/ct/tasks/cmviewer/gui/progress_bar.gif")));       
          JPanel iconPanel = new JPanel();
          iconPanel.add(buildingIcon);
  
          //Build the textArea
          JTextArea textLog = new JTextArea("Say something");     
          JPanel textPanel = new JPanel();
          textPanel.add(new JScrollPane(textLog));
  
          //Add the panels to the layered pane
          lpane.add(textPanel, 0);
          lpane.add(iconPanel, 1);
  
          frame.pack();
          frame.setVisible(true);
      }
  
      public static void main(String[] args) {
          new TestLayeredPanes();
      }
  
  }
  </code></pre>