how to add labels without them overlapping each other
<p>I wanted to add 2 labels in my JDialog; one label will have animated gif ; other will have text. How to add these two so that they dont overlap? I don't want to hardcode their positions. I want the program to make the inherent adjustments.</p>

<p>Thanks in Advance</p>

<p>code:  </p>

<pre><code>     JLabel l2=new JLabel("");
     try {

          Image img = ImageIO.read(getClass().getResource("resources/wait_animated.gif"));
          ImageIcon imgnew=new ImageIcon("G:\\my java\\DesktopApplication1\\src\\desktopapplication1\\resources\\wait_animated.gif");
          l2.setIcon(imgnew);
          imgnew.setImageObserver(l2);
     }
     catch (IOException ex) {
     }
     l2.setLocation(300,300);
     JDialog d=new JDialog();
     JLabel l=new JLabel("Please Wait While Processing is Done...        ");

     JDesktopPane dp=new JDesktopPane();
     dp.setPreferredSize(new Dimension(300,50));
     l.setPreferredSize(new Dimension(250,50));

     l2.setPreferredSize(new Dimension(20,20));

     d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
     d.setTitle("Wait dialog");
     d.add(l);
     d.add(l2);
</code></pre>
