JPopupMenu - disabling mouse right click

Hi,
First of all, before I write the problem here, I searched a lot but I actually could not find the desired solution.
The problem is;
I have a JPopupMenu. As you know, all mouse clicks (left click, middle click and right click) do the selection in popup menu and then it tries to perform the related action. Finally, the popup menu disappears. But, what I want actually is that "my popup menu will not respond to the mouse right click and will not disappear after that right click".
Can anyone say how to make that happen?
Thanks a lot.

The following is an example code, and I did not the details of how the popup menu showed. I just showed how the actions are added to the popup menu elements. In this example, in the popup menu there are Text1, Text2 and Text3 selections and their actions are added like in the code. So, my actions are seperate for each element in the popup menu. Now, how can I make the mouse right click will not enter the related selection's actionPerformed (e.g; Text1, Text2) and the popup menu will not disappear?
public class JPopupMenuTest {
    public static void main(String[] args) {
        JPopupMenuTest popupTest = new JPopupMenuTest();
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(popupTest.new Text1Action());
        popupMenu.add(popupTest.new Text2Action());
        popupMenu.add(popupTest.new Text3Action());
    class Text1Action extends AbstractAction {
        public Text1Action() {
            super("Text1");
        @Override
        public void actionPerformed(ActionEvent e) {
            // Here is the Text1 action performed
    class Text2Action extends AbstractAction {
        public Text2Action() {
            super("Text2");
        @Override
        public void actionPerformed(ActionEvent e) {
            //  Here is the Text2 action performed
    class Text3Action extends AbstractAction {
        public Text3Action() {
            super("Text3");
        @Override
        public void actionPerformed(ActionEvent e) {
            // Here is the Text3 action performed
}

Similar Messages

  • Disable Mouse Right click inside Adobe Acrobat PDF plugin

    Hi All,
    We are rendering Adobe live cycle pdf file inside html object tag.
    I have disabled toolbar , navigation bar using navpanes=0&toolbar=0.
    But when mouse right click reenable the context menu again.
    So Is there any way to disable mouse righ click inside Adobe Acrobat PDF browser plugin?

    I had the same problem after updating Firefox to version 4.0 and Acrobat Reader to Version X. For me (Win XP) what solve the problem was deleting the Acrobat Reader Plugin (nppdf32.dll) in the Firefox plugin folder (C:\Program Files\Mozilla Firefox\plugins). So now there is only one Acrobat Reader Plugin left namely the one in the Acrobat Reader plugin folder (C:\Program Files\Adobe\Reader 10.0\Reader\Browser).

  • MenuEditor addon ~ disables mouse right click

    I recently upgraded my PC from intel atom to intel i3.
    during reinstallment of firefox. i found that (after checking) the MenuEditor Addon disables my right click in firefox.
    Previously it used to work smoothly even in firefox v27, but now does not respond even in firefox v25.0
    can you please guide me for that
    regards,
    aebbee

    Try to disable hardware acceleration in Firefox (you need to close and restart Firefox).
    *Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How can i disable mouse right clicking event

    I need in my project to disallow any body to right click the mouse. Can i disable this event to prevent user of the application from right clicking if yes how can i disable it.

    I have code written in Visual Basic doing the same task but i don't know how to transfer those code in java
    The following is a code for that:
    Option Explicit
    'declares
    Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
    Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
    Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
    'constant
    Private Const WH_MOUSE_LL = 14&
    Public Const HC_ACTION = 0&
    Public Const WM_RBUTTONDOWN = &H204
    Public Const WM_RBUTTONUP = &H205
    Public Const VK_RBUTTON = &H2
    Private lMShook As Long
    Private bHookEnabled As Boolean
    'functions which process mouse events
    Public Function MouseProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    If nCode = HC_ACTION Then
    If (wParam = WM_RBUTTONUP Or wParam = WM_RBUTTONDOWN) Then
    MouseProc = 1
    Exit Function
    End If
    End If
    MouseProc = CallNextHookEx(lMShook, nCode, wParam, lParam)
    End Function
    Public Function SetHook()
    If lMShook = 0 Then
    lMShook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0&)
    End If
    If lMShook = 0 Then
    MsgBox "failed to install hook :" & lMShook & " : " & WH_MOUSE_LL
    bHookEnabled = False
    Unload Form1
    Exit Function
    Else
    bHookEnabled = True
    End If
    End Function
    Public Function UnSetHook()
    If bHookEnabled Then
    Call UnhookWindowsHookEx(lMShook)
    lMShook = 0
    End If
    bHookEnabled = False
    End Function
    Public Function InstalledHook()
    MsgBox " installed hook is :" & lMShook
    End Function
    code for form is below:
    Option Explicit
    Private Sub Command1_Click()
    InstalledHook
    End Sub
    Private Sub Command2_Click()
    Call SetHook
    End Sub
    Private Sub Command3_Click()
    Call UnSetHook
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
    Call UnSetHook
    End Sub

  • Facing Strange Problem in DIR HOW TO DISABLE THE RIGHT CLICK MOUSE IN THE DIRECTOR? (through parent script/ movie?)

    Summary : HARD QUESTION : In the DIR file, the game runs well, right click = no effect. Coz I'm not making right click scripts. BUT in EXE file, right click = ERROR.
    Explanation :
    In the Adobe Director screen, this DIR file game is worked 100%.
    I tested right click EVERYWHERE... NOTHING HAPPENS.
    Because I don't make any programming with "on rightmouseup" or "on rightmousedown" command.
    THEN, I published it into EXE...
    I tested right click EVERYWHERE...I hoped the result will be the same as DIR tests....
    WHEN I RIGHT CLICK IN THE AREA THAT'S GIVEN ON EXITFRAME ME, IT SHOWS ERROR, CHANGING PICTURES.....
    this does not happened in the DIR file...
    I didn't make a runmode program or anything else.... This is awkward... mystery for me...
    WHY THERE'S A DIFFERENCE IN DIR and EXE... it should be exactly the same result.
    I have used Director for years.... This is really strange for me...
    >>>>>>>>HOW TO DISABLE THE RIGHT CLICK MOUSE IN THE DIRECTOR?
    THIS ONE is useless.... It doesn't prevent the rightmouse click,...
          on rightmouseup me
                 nothing
         end
          on rightmousedown me
                 nothing
         end

    Dear Adobe Forums friends
    I need your help and guide through this problem...
    In the game's dir file that is run on the DIRECTOR softwawre,
    the game runs perfectly, I can do LEFT CLICKS (coz I programmed the script)
    and when I do RIGHT CLICKS = there are no effect ( coz I don't do script for it)
    LATER THIS GAME TURNED INTO EXE.
    It supposed to run like the dir file as ABOVE. BUT STRANGELY, WHEN
    I DO RIGHT CLICKS, it turns Error and showing as the picture attachment.
    The right clicks that goes error are above the picture of numeric button only. (in DIR file
    this run normal). I looked into the script behind the numeric button picture, there are only "on exitframe me", there are no script I made inside the "on exitframe me" that is triggering RIGHT CLICKS.
    1. I wonder why there are differences in DIR and EXE effect
    2. Why right click? Left click effects are all normal.
    3. IS THERE ANY WAY TO DISABLE ALL RIGHT CLICKs since the beginning of EXE. So the game will be run normal. I don't need right clicks anyway, but whenever people do right click there will be ERROR.??
    4. Is there any way to STOP THE MESSSAGE BOX TO APPEAR IN FRONT OF THE GAME? (I hate the Dirrector Error Message Box), or auto press OK.
    NB: this game uses Buddy API Xtras, File IO Xtras.
    Thx
    David S

  • How to activate mouse right click in JTexhArea

    Hi Swings Expert!
    I've a problem to get action mouse right click in JTextArea for example to cut and paste selected text from textarea into another textarea.
    If I want to copy and paste text from textarea, Ive to use Ctrl C for copy
    and Ctrl V for paste the selected text.
    Is there a way to activate mouse right click in JTextArea?
    any help.....Thanks a lot.

    Here are the basics:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    public class PopupMenuTest extends JFrame implements MouseListener
         public JPopupMenu popup;
         public PopupMenuTest()
              popup = new JPopupMenu();
    //          popup.add( new DefaultEditorKit.CutAction() );
              JMenuItem item = new JMenuItem( new DefaultEditorKit.CutAction() );
              item.setMnemonic('C');
              popup.add( item );
              popup.add( new DefaultEditorKit.CopyAction() );
              popup.add( new DefaultEditorKit.PasteAction() );
              JTextField textField = new JTextField("Right Click For Popup");
              textField.addMouseListener( this );
              getContentPane().add(textField);
         private void checkForPopup(MouseEvent e)
              if (e.isPopupTrigger())
                   popup.show(e.getComponent(), e.getX(), e.getY());
         public void mousePressed(MouseEvent e)
              checkForPopup( e );
         public void mouseReleased(MouseEvent e)
              checkForPopup( e );
         public void mouseClicked(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         public static void main(String[] args)
              PopupMenuTest frame = new PopupMenuTest();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.show();
    }

  • My iMac mouse right click does not work now

    Hi all,
    My iMac mouse right click does not work now.  It was fine a couple of days ago. 
    Right click is definitely enabled, I have checked it several times.
    A Google search revealed that in Firefox it could be that I'm not using the latest version of Firebug.  I have auto updates on and Firebug is the latest version 1.11.3
    I use right click for correcting spell checked words, instead of a suggested correct spelling I get the 'open in a new tab' menu.
    In Firefox when I right click to open in a new tab I get the menu but it does nothing.
    It is driving me mad
    Any help will be greatly appreciated,
    Thank you
    P.S. thought it was suddenly working when I did the spell check in this post but it was the left click doign it....

    I don't use Firefox so I can't test it, but it might be something to do with a preference setting. Have a look at this link (ignore all the instructions), just look at the image of the preferences, there appears to be a setting in Javascript preferences relating to contextual menus. Check to see what your settings are:
    http://stackoverflow.com/questions/16377381/disable-firefoxs-silly-right-click-c ontext-menu

  • Magic mouse right click problem in Mountain Lion

    Hi!
    My Magic mouse right-click doesn't work in Mountain Lion! in previous OSes it was working properly (Leopard and Lion), but when I upgrated to Mountain, this problem occured.
    if you click anywhere on the magic mouse, it simply do a click, not a right-click anyway...
    I did a lot of searches and changes but the problem is still alive...
    somewhere suggested disabling "Secondary Click", then restart, and then enabling it. but nothing changed...
    somewhere suggested to remove two files named "com.apple.Bluetooth..." in /Library/Preferences, and then restart the system, but this not worked for me, too...
    I changed the "Secondary Click" to "Click on the left side" but nothing changed and the magic mouse did just clicking and not right-clicking!
    I wondered what can I really do to solve this problem?!
    any suggestion is appreciated...

    I still use the magic-mouse and still it's not stable. I've found theONLY way to overcome the rightclick is to make sure that you're NOT pressing anywhere else on the mouse (even touching) and only pressing at theTOP right-hand most corner.
    It's not the best resolution, but the best that Applecare could provide me with. I thinjk, because it's relatively new due to the new generation of capacitive touch devices that we all get the bugs/flaws.
    As like the iPhone, although an EXCELLENT device, and the various versions of OSX, we're going to be plagued eith bugs until a newer review comes out.
    The way I found out was to use BOTH tools (MagicPrefs and BetterTouchTool) together, and in both set the Rightclick sensitive area to a near nothing for system wide (non app specific).
    It does fail at times on some apps, and takes a few clicks, but 90% of the time it's cleared up.
    I somehow think that most developers (and yes its the developers not apple) that forget that we rest out palms on the mouse) and they don't filter out the events forrectly (i.e. a palm on the mouse is seen as a tap). Othere works well, for exmaple I use photoshop, which adapted well to the mouse. The majority of games, and including those (ESPECUALLY THOSE) flash mbased, don't like the mouse at all!

  • Mouse Right Click

    Hello all,
    How to track mouse right click in Oracle Forms? I have a form which has a popup menu, based on the item status i have to enable and disable some options in the popup menu. Any ideas?
    With Regards,
    Yathish

    try the PRE-POPUP-MENU - trigger

  • Prevent Mouse right click

    Hi all,
    In web browser how can we prevent the mouse right click for our web pages
    regards,
    Mahe

    edng wrote:
    you guys are funny
    you can prevent someone from right click the mouse. i've seen web pages implementing this feature. when you right click, it says 'this function is disabled'
    its no different than people streaming and when you right click on the stream you get nothing cause its block so you cannot tell the properties etcNot really, it only gives the illusion that it was disabled. You could possibly turn off Javascript to enable it. You could use another browser that does not support this "feature" or gives you more control. You could used greasemonkey as pm_kirkham said.
    The point is that all the things that appear to happen are only because Internet Explorer (or whatever) allow the �feature�. If your code relies on browser tricks to be valid then the code is broken. Browser edits, etc. should only be used to make the application more user-friendly but should work even if the features are not available in the browser.

  • Why keyboard and mouse right click not working in Solaris and Linux?

    Hi all,
    I have two problems:
    1) I am working on AWT/Swing application and its working fine in window enviornment,but while running on solaris and linux mouse right-click option window not poping up.
    2) Ctrl+c,Ctrl+v,Home and End keyboard key are not working in solaris and linux OS for same application.
    Pls provide me some solution for these problem.
    -Dinesh

    Hi Nik,
    Thanks for reply. I found some solution for the above problem.
    For mouse right click there was problem in my source code.I have not implemented the mousePressed() method
    In case of keyboard Home, End and arrow key working fine after exporting AWTUSE_TYPE4_PATCH=false; in solaris and linux
    But still Ctrl-c and Ctrl-v not working.
    I am using JDK1.5.0_07+Eclipse IDE 3.1
    -Dinesh

  • Mouse right-click function doesn't work in Bookmarks (Mac)

    I recently switched from PCs to Macs. No problem downloading Firefox and transferring old bookmarks and other settings, with one exception. With the PCs, when I right-clicked a particular bookmark under Bookmarks I got a series of 12 options (from Open, Open in New Window to Delete, Sort by Name, Properties). I used these a lot to delete bookmarks, change names, alphabetize lists, etc. I can now do most of these things under the Manage Bookmarks setting, but when I right click bookmarks now the new bookmark I click on just replaces the one on screen (ie, the right click does exactly what the left click does). I am using two different mice (Apple Mighty Mouse with Leopard, Microsoft Wheel Mouse with Tiger) and the right click function behaves as expected in other programs. Are these mouse right click Bookmark functions supposed to appear with the Firefox for Mac? If so, any ideas how to resolve my problem?

    Can someone explain to me why it's possible in Chrome on Mac, but not on Firefox? This is my 2nd biggest complaint about FF on the Mac, only surpassed by missing favicons in bookmarks. Chrome does both very well.

  • CommandLink on mouse right click!!!

    Hi all,
    I have a problem in CommandLink,when i use mouse right click open in new tab or open in new window over the CommandLink it shows a previous page instead of actual page.I tried to overcome this using <redirect/> tag in faces-config xml but its a vain eventually.
    No request is generated to server while trying open in new tab.
    Any of u ever had this issue,any suggestions???.
    Awaiting reply.
    Thanks in advance,
    sundar.

    sundar82 wrote:
    Hi all,
    I have a problem in CommandLink,when i use mouse right click open in new tab or open in new window over the CommandLink it shows a previous page instead of actual page.I tried to overcome this using <redirect/> tag in faces-config xml but its a vain eventually.
    No request is generated to server while trying open in new tab.Which browser are you using?

  • Thunderbird Crashes on selection +"ctrl+c" or mouse right click

    Whenever I attempt to copy text from within a mail message, by selecting text & pressing ctrl+C TB crashes,
    or Just on Mouse Right Click TB Crashes

    So, I finally did a fresh install of OSX on iMac, and the right click came back.
    I think there was something corrupted on the system that somehow showed up after Adobe CS2. I reinstalled CS2 but up to now, no problems at all.
    Thanks all for the insights, they all helped a lot!

  • I HAVE IMAC 27 INCH MY MOUSE RIGHT CLICK IS NOT WORKING PROPERLY .ANY ONE HAVE HIS PROBLEM

    I HAVE IMAC 27 INCH MY MOUSE RIGHT CLICK IS NOT WORKING PROPERLY .ANY ONE HAVE THIS PROBLEM

    Have you tried going to System Preferences>Mouse and making sure that right click is set to secondary click?

Maybe you are looking for