a netbeans rcp blog

No, I don’t want to rename my node

Posted by Nicklas Löf on February 14, 2011

Two weeks ago I needed to make my Outlineview readonly. All properties it’s showing was only for read and all changes was gonna be done in a separate editor window.

Making the properties read only is very easy. If you are using BeanNodes just edit the BeanInfo and select Read-only on each property. If you are using AbstractNodes you probably are creating your own propertyset and if I remember correctly just include the getter and the property will be read only.

So now everything is ok but I did discover that in the tree column of the outlineview I could double click on the node name and rename the node. This was something I didn’t want to do and I started to look around how to fix this. All I could found was suggestions that Overriding getPreferredAction and set the action I want to execute when I double click on my node. If this is set to null no action will be executed. But still I could double click on the name and the node was renamed.

The solution was easy..   override canRename() and return false and booom it’s not possible to rename the node name anymore!


One Response to “No, I don’t want to rename my node”

  1. nootropics said

    Wow lots of beneficial knowledge!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: