Ei cara, eu fiz aqui. De acordo com a hierarquia dos componentes deveria funcionar, teoricamente. Mas na pr�tica acredito que n�o seja aplic�vel.
De qualquer forma, a� vai o exemplo que insere no JDesktopPane que est� dentro de um JScrollPane.
 
Lembre-se: o usu�rio poder� iconizar as JInternalFrames's, assim n�o deixando o desktop totalmente cheio. A n�o ser que voc� abra uns 1000 frames. =]
 
Espero ter ajudado.
 
import javax.swing.*;
import javax.swing.JComponent.*;
import java.awt.*;
import java.awt.event.*;
 

public class FrameDeskextends JFrame implements ActionListener {
 
 public FrameDesk() {
  
  JDesktopPane desktop = new JDesktopPane();
  desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
  JScrollPane scroll = new JScrollPane(desktop);
  
  JButton button = new JButton("IFrame");
  button.setActionCommand("CLICK");
  button.addActionListener(this);
  
  this.getContentPane().add("North",button);
  this.getContentPane().add("Center",scroll);
  this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.setSize(this.getMaximumSize());
 }
 
    public JDesktopPane getComp(JFrame frm) {
 
        Component [] comp = frm.getContentPane().getComponents();
        JDesktopPane desktopPane = null;
  
        for (int i = 0; i < comp.length; i++) {
 
            if (comp[i] instanceof JScrollPane) {
    desktopPane = (JDesktopPane)((JScrollPane)comp[i]).getViewport().getView();
                break;
            }
 
        }
 
        return desktopPane;
    }
 
 public void actionPerformed(ActionEvent ae) {
  if (ae.getActionCommand().equals("CLICK")) {
   JInternalFrame iFrame = new JInternalFrame("IFrame",true,true,true);
   this.getComp(this).add(iFrame);
   iFrame.setVisible(true);
   iFrame.pack();
  }
 }
 
 public static void main(String [] args) throws Exception{
  new FrameDesk();
 }
 
}
 
 
Atenciosamente,
 
Wilder C. Rodrigues
Sun Certified Programmer for Java 2 - Platform 1.4
Sun Certified Developer for Java 2 Standard Edition - Platform 1.4
Sun Certified Web Component Developer for Java 2 Enterprise Edition - Platform 1.3
JUGLeader
Unimed Fortaleza - Projeto Sabius
[EMAIL PROTECTED]
http://planeta.terra.com.br/informatica/javanow
 
The new Marillion's album is coming - Marbles
www.marillion.com

Responder a