februari 14, 2011

No, I don't want to rename my node

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!