• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

How Dynamic JPopupMenu in swing?

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic