JTree and right click popup menu ?
Posted on 2002-07-18
Well I have a JTree which is made using DefaultMutableTreeNode with userObjects.
Now also I have as a standard certain actions which I can perform on a node when I right click on the node. Thus for that I have a popup menu.
The popup menu has following actions which I can perform on the particular node.
7. Move (using self makde DND by implementing MouseMotionListener)
Now to enable or to disable these options the rules are all lying in DefaultMutableTreeNode instance.
How should I have a set pattern to make this enable/disabling feature execute.
The situation is like if the node has its beans deleteFlag() set to true the all options have to be disabled except for undelete.
If the archiveFlag() is true then only unarchive and delete options have to enabled rest all disabled.
I mean I want to have a object oriented solution to this problem instead of getting lost in -- if and else if statements.
Kinldy demostrate me with a scalable solution so that I can really work well for the same in not only robust but ease of use way.
Thanx in advance.