Google

Monday, May 19, 2008

How to Create MDI App in Netbeans

YouTube - How fast we create MDI forms with Netbeans


Below is Inticas003:



It is an MDI Implementation of the previous Inticas. The two applications :

1. File Chooser (which allows you to select any text file to open and view)
2. Xml Dom Demo (which opens the file 'employees.xml' and displays its contents)

is now implemented within two different Frames (Forms).

The Xml Dom Demo now displays the exmployees.xml content within the Frame (form) instead of at the bottom of the Netbeans IDE.

The steps for building Inticas003 follows.

1. Create a new project.
Select a Java Desktop Application

2. Add a Desktop Pane from the Swing Containers Pallette

3. Add a new Menu to the Menu Bar and call it Applications

4. Add two Menu Items fo the above new Menu Bar called
File Chooser Demo
Xml Demo

5. Add two new JInternalFrames to the Project called:
FileChooserFrame
XmlDemoFrame

6. To each of the above new Frames in 5 above, add the respective Menu Bars and
JTextArea objects

7. Add code to implement the menuitems in 6 above

8. Go back to the MainFrame called InticasView.java (this is the parent Frame)
and implement the code for the FileChooser menuitem and XmlDemo menuitem.

9. To enable the two new frames to be called, u need to add them to the Desktop Pane
created in Step 2 above:

private void fileChooseMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
FileChooserFrame fc = new FileChooserFrame();
desktop.add(fc);
fc.setVisible(true);

}

private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
XmlDomFrame xf = new XmlDomFrame();
desktop.add(xf);
xf.setVisible(true);
}


desktop is the name of the JDesktopPane

Note that if you do not add them to the JDesktopPane, the child windows will not be able to become the top focussed window when u click on them, and also will not be able to iconify (minimize).