[Java] MDI-Child hinzufügen

// Funktion addChild fügt ein neues MDI-Child vom Typ JInternalFrame zum MDIParent (JDesktopPane) hinzu
private void addChild(javax.swing.JDesktopPane MDIParent, String caption, int x , int y, int w, int h,
        boolean selected, boolean maximizable, boolean closeable,
        boolean iconifiable, boolean resizable)
{
    MDIChild c = new MDIChild();
    
    MDIParent.add(c);
    
    c.setTitle(caption);
    c.setVisible(true);
    c.setLocation(x, y);
    c.setSize(w, h);
    
    c.setMaximizable(maximizable);
    c.setClosable(closeable);
    c.setIconifiable(iconifiable);
    c.setResizable(resizable);
    
    try
    {
        c.setSelected(selected);
    }
    catch (java.beans.PropertyVetoException e) {}
}

[Java] Mit MDI-Forms arbeiten

  1. neues Projekt anlegen: File->New Project->Java->Java Application
  2. MDI-Parent Formular im Projekt anlegen: File->New File->Swing GUI Forms->JFrame Form
  3. Desktoppane (jDesktopPane1) auf das MDI-Parent ziehen: Design->Palette->Desktop Pane
  4. MDI-Child Formular im Projekt anlegen: File->New File->Swing GUI Forms->JInternalFrame Form
  5. MDI-Child im Code erzeugen:
    NewJInternalFrame c = new NewJInternalFrame();
    jDesktopPane1.add(c);
    c.setVisible(true);
    

Links: