How to remove or disable a menu item from a JPopupMenu?

1.5k Views Asked by At

I have a JPopupMenu and I want to disable or remove, if possible, a menu item every time an action happens. So I tried this, and though the removeCommentAction object is added in the position 4 of the menu, the menu item in position 4 is not removed. I know about the menu item method setEnabled but how can this be implemented in this case with the AbstractAction object?

        nodeMenu.remove(4);
        nodeMenu.insert(new RemoveCommentAction(),4)

Thank you.

0

There are 0 best solutions below