Hello guys,
I just want to ask something if is it possible to remove JMenu.addSeparator()
after it is being called? for example in my form there is a menu bar and inside the menu bar lets say there are three JmenuItems
and each of it has JMenu.addSeparator()
. What i want to do is, if a different user is log in I want to setVisible(false)
one of JMenuItem
because that particular user in not authorize to use that JMenuItem
. The problem is when I setVisible(false)
one of the JMenuItem
the JMenu.addSeparator()
still exist which kinda awkward to watch since there are no JMenuItem
exist in the middle of two JMenu.addSeparator()
. Hope you can help me with this problem.
Thanks in advance
You have two possible solutions...
You Could...
Remove the contents of the menu and rebuilt it based on what the user can do...
This would be my preferred solution...
You Could...
Hide/show the menu items based on what the current user can actually do and then remove all the
JSeparator
s that appear next to each other, for example...Personally, I know which I would prefer and generally, which would produce consistent results...