Geertjan's Blog

  • October 10, 2007

Listening to the Changing of Marilyn Monroe's Properties

Geertjan Wielenga
Product Manager
I found a great tip in the NetBeans Developer FAQ today. In DevFaqPropertySheetNodes, it turns out that if your TopComponent implements a PropertyChangeListener (together with the ExplorerManager.Provider which it is already implementing), then you can add a PropertyChangeListener to the explorer manager. When you do that, you can listen for the currently selected node in the view and then set the activated node on the TopComponent, as shown here:

public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == manager && ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {

This will result in the IDE's (or your application's) Properties sheet showing the properties of the currently selected node, as shown here:

I guess the above would make more sense if I had more properties. They wouldn't all be visible in the view at the same time, but I would be able to see them at one glance, listed in the Properties sheet. As you can see, all the attributes of the cell in the table (such as, here, its background color) are visible in the Properties sheet! Maybe you don't want that and you would then change the paint method, via the propertyChange above. And all of this is a clear example of why it made sense for me to move the TreeTableView from my J2SE application to the NetBeans Platform. Before, in my J2SE application, I had a single frame, i.e., no Properties sheet such as the above. Now that my TreeTableView is on the NetBeans Platform, I immediately have a Properties sheet at my disposal. And to enable it, all I needed to set was a property change listener!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.