Own JPopupMenu

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Own JPopupMenu

Postby theuserbl » Mon Apr 05, 2010 1:39 pm


http://www.fifesoft.com/rsyntaxtextarea ... ample3.php
you describe how to extend the current JPopupMenu.

But I wanrt to have my own one.

Is it possible to empty the existing one, so that I can fill it like in example3 with all of my own selections?
Or is it possible to disable it?

I have created my own one. On windows it replaced completely yours.
But on Linux, after my own JPopupMenu closed, yours opened. So it would be helpful, if there is a possibility to disable yours or to empty it, so that I can fill it completly myself.

Posts: 15
Joined: Sun Mar 28, 2010 2:37 pm

Re: Own JPopupMenu

Postby robert » Tue Apr 06, 2010 3:54 am

How did you set your own custom popup menu? Did you use setPopupMenu() (or createPopupMenu() if you're overriding RSyntaxTextArea) as suggested in the demo?

To "override" the standard RSTA popup, I see two possible routes you can take:

  • Call textArea.setPopupMenu(myPopup), where "myPopup" is your popup menu.
  • Call textArea.setPopupMenu(null), then call textArea.setComponentPopupMenu(myPopup). This will only work with Java 5+ (which you almost certainly are using).

The only reason RSTA defines "setPopupMenu()", "getPopupMenu()" and "createPopupMenu()" methods is because RSTA is usable in Java 1.4, whereas the Java API for context menus (get/setComponentPopupMenu()) was added in Java 5. So you can either use RSTA's API and not use Java's standard API, or set the RSTA-specific context menu to "null" and use the methods added in Java 5 exclusively.

If you're having trouble, feel free to post some code showing what you are doing.
User avatar
Posts: 818
Joined: Sat May 10, 2008 5:16 pm

Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest