title: Embed JPanel in JApplet (always on top)
body: <p>I have a hybrid swing application which can be run as applet or java application with the following structure:    </p>
  
  <pre><code>public class Gui extends JApplet {
  
      public void init() {...}
  
      public void paint(Graphics g) {
         ...
         g.drawImage(image, 0, 0, this);
      }
  
      public static void main(String args[]) {
  
         JFrame frame = new JFrame();
         JDialog dialog = new JDialog(frame);
  
         Gui gui = new Gui();
         gui.init();
         gui.start();
  
         dialog.add("Center", gui);
  
         ...
      }
  
  }
  </code></pre>
  
  <p>The whole gui consists of one drawing area which is continously updated.
  I would like to embed a panel which is always on top and independent of the underlying drawing process.</p>
  
  <p>I tried using JLayeredPane and add it between JDialog and JApplet, but Japplet cant be added to the Pane because it is a top level container.</p>
  
  <p>I also tried realising it with the glasspane but no success at all.</p>
  
  <p>Is there a solution without refactoring to much since the structure should be kept as far as possible.</p>