Migrating from TreeTableView to OutlineView
By Geertjan-Oracle on Aug 15, 2008
- Install the Marilyn TreeTableView Sample.
- Create the sample, i.e., choose "Samples | Java | Marilyn" in the New Project wizard and complete the steps in the wizard.
- Add the following JARs from "platform9" folder in the NetBeans installation directory to the app's classpath: org-openide-actions.jar, org-openide-awt.jar, org-openide-dialogs.jar, org-openide-explorer.jar, org-openide-nodes.jar, org-openide-util.jar.
- Run the application to check everything is working and that you're set for migration.
- Open demo.MyFirstFrame.java in the Design view. Delete the Swing component you find there, which is the TreeTableView.
- Right-click in the Palette to the right of the Design view and choose Palette Manager. Click "Add from JAR" and browse to "org-openide-explorer.jar". From the list of available components, choose "OutlineView" and click Next. Add it to any palette category and then click Finish.
- From the "platform9" folder, add the org-netbeans-swing-outline.jar onto the app's classpath.
- From the category where you added the "OutlineView" component, drag it onto the JFrame. Then switch to the Source view.
- Change these lines:
To these lines:
- Run the application again and now you have the same result as before, except that you're using "OutlineView" instead of "TreeTableView".
In other words, you're using the same concepts as before, i.e., the Nodes API, the ExplorerManager, and the NodeTableModel. However, the explorer view is changed to one that is not buggy (which was the original reason for replacing TreeTableView) and has a few extra features, based on the "Outline" component. These additional features will be discussed here soon.