Problemas com jInternalframe

Pessoal,

Estou chamando um jInternalFrame de um Frame que contem varios Jpanel. Porém o jInternalFrame fica por traz de todos Jpanel.

Alguém sabe me ajudar?

JInternalFrame foi projetado para ser inserido num JDesktopPane, não no contentPane de um JFrame (na verdade, o contentPane nada mais é que um JPanel). Para obter o efeito desejado, insira um JDesktopPane no contentPane do JFrame, e em seguida insira o JInternalFrame no JDesktopPane.

Desse jeito?

JInternalFrame iFrame = new JInternalFrame();
JDesktopPane desktop =new JDesktopPane();
iFrame.add(desktop);

   desktop.add(jInternalFrame1);
   jInternalFrame1.setVisible(true);

Quase isso. Assim:

JDesktopPane desktop =new JDesktopPane();
JInternalFrame iFrame = new JInternalFrame();
iFrame.setLocation(10, 10);  // É preciso definir a posição explicitamente
iFrame.setSize(50, 50);  // E preciso definir o tamanho explicitamente
iFrame.setVisible(true);
desktop.add(iFrame);
iFrame.setSelected(true);

No mais, não precisa criar um novo JDesktopPane a cada novo JInternalFrame que adicionar. Crie apenas um JDesktopPane, no início da aplicação, e vá adicionando JInternalFrame’s a ele conforme a necessidade.

Não funcionou, eu tentei do jeito abaixo:

JDesktopPane desktop = new JDesktopPane();
JInternalFrame internal = new JInternalFrame();
internal.setLocation(411, 50);
internal.setSize(100, 100);
internal.setVisible(true);
desktop.add(jInternalFrame1);
internal.setVisible(true);

Segue um programa de exemplo, espero que ajude:

import java.awt.BorderLayout;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class FramePrincipal extends JFrame {
  public FramePrincipal() {
    super("JFrame contendo JDesktopPane");
    setLocation(50, 50);
    setSize(500, 500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setLayout(new BorderLayout());

    JDesktopPane desktopPane = new JDesktopPane();
    add(desktopPane, BorderLayout.CENTER);

    JInternalFrame internalFrame = new JInternalFrame(
      "JInternalFrame", true, true, true, true);
    internalFrame.setLocation(10, 10);
    internalFrame.setSize(250, 250);
    internalFrame.setVisible(true);

    desktopPane.add(internalFrame);

    try {
      internalFrame.setSelected(true);
    } catch (Exception ex) { }
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      @Override public void run() {
        try {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) { }

        JFrame framePrincipal = new FramePrincipal();
        framePrincipal.setVisible(true);
      }});
  }
}