Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How Dynamic JPopupMenu in swing?  RSS feed

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have swing JPopupMenu like

protected JPopupMenu remoteTreePopup;

remoteTreePopup.add(createFolderAction);
remoteTreePopup.add(editItemAction);
remoteTreePopup.add(removeItemAction);
remoteTreePopup.addSeparator();

according to the above code,
if i right click the swing jpopupmenu, all the 4 label actions will be default actions.

how can I allow/view createFolderAction only.

Please give some ideas.

Thanks and Regards,
Edward
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i right click the swing jpopupmenu, all the 4 label actions will be default actions.

Not really. A "default" action is usually the action fired on specific triggers like double click or hitting return. e.g. In Windows explorer, if you right click on a drive (c:,d: etc) the "default" action is "explore". The visual clue associated with the default action, is that the text is bold.


how can I allow/view createFolderAction only.


1) Disable all other actions.
2) Don't add them to the popup.
3) If already added, remove them from the popup.

The way it usually done is using #1 above.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!