// 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) {}
}
Schlagwort: JInternalFrame
[Java] Alle MDI Childs auflisten
// jDesktopPane1 ist das Swing-Objekt, welches alle Childs verwaltet
JInternalFrame[] children = jDesktopPane1.getAllFrames();
for (JInternalFrame f : children)
{
// ...
}
[Java] Mit MDI-Forms arbeiten
- neues Projekt anlegen: File->New Project->Java->Java Application
- MDI-Parent Formular im Projekt anlegen: File->New File->Swing GUI Forms->JFrame Form
- Desktoppane (jDesktopPane1) auf das MDI-Parent ziehen: Design->Palette->Desktop Pane
- MDI-Child Formular im Projekt anlegen: File->New File->Swing GUI Forms->JInternalFrame Form
- MDI-Child im Code erzeugen:
NewJInternalFrame c = new NewJInternalFrame(); jDesktopPane1.add(c); c.setVisible(true);
Links: