I have a custom object that has a description (String) and priority value (int). I display these values in a JTree because there is a hierarchical relationship between different objects of this type. I only display the description in the JTree nodes because the priority is not important for display purposes.
I would like to have a JDialog pop-up when I edit a JTree node (leaf or node) - for example by pressing F2. This dialog will then be used to edit both the description and the priority.
How do I prevent the JTree from performing the default editing of the text as a text field and call up the custom dialog instead?
An easy way I suppose would be to subclass the DefaultTreeCellEditor class and override the isCellEditable method. Then, I would invoke the JDialog there (I can obtain the relevant initialization elements when I instantiate the custom DefaultTreeCellEditor) and simply return false to prevent the default editing - but this to me doesn't seem elegant enough.