• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to remove menuitem from context menu (SWT)

 
Isaac Jones
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everybody

can someone tell me how i can remove a menuitem from a context menu or even better how i can clear all items from a menu (like resetting the menu). i couldn't find any remove method or so. depending on the selected item i want different entries in my context menu. any ideas?

regards
 
Campbell Ritchie
Marshal
Posts: 52567
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are about three methods in JMenu which remove things. A different route, which some people prefer, is to use the setEnabled() method on the individual items, which is how menu items change from active (black writing default) to inactive (grey writing).
 
Isaac Jones
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this works for swt too?
 
Campbell Ritchie
Marshal
Posts: 52567
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SWT? No idea. I have never actually used it. I have always written GUIs the hard way:-
add(startButton = getJButton("Start", 's', "Start the application, new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
myFoo.start();
}
});
etc etc
You will have to try those methods, and see which works. CR
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!