Friday Aug 15, 2008

Migrating from TreeTableView to OutlineView

Here, based on an existing example, is how to migrate from "TreeTableView" to the new NetBeans Platform 6.5 "OutlineView":
  1. Install the Marilyn TreeTableView Sample.

  2. Create the sample, i.e., choose "Samples | Java | Marilyn" in the New Project wizard and complete the steps in the wizard.

  3. 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.

  4. Run the application to check everything is working and that you're set for migration.

  5. Open demo.MyFirstFrame.java in the Design view. Delete the Swing component you find there, which is the TreeTableView.

  6. 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.

  7. From the "platform9" folder, add the org-netbeans-swing-outline.jar onto the app's classpath.

  8. From the category where you added the "OutlineView" component, drag it onto the JFrame. Then switch to the Source view.

  9. Change these lines:
    treeTableView1.setProperties(props);
    treeTableView1.setRootVisible(false);

    To these lines:

    outlineView1.setProperties(props);
    //treeTableView1.setRootVisible(false);

  10. 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.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« August 2008 »
SunMonTueWedThuFriSat
     
2
4
5
6
7
11
14
17
20
23
27
29
30
31
      
Today