Right click selection

Hello,
can i make selection in JList by right mouse click?
thanks

you can test (MouseEvent)e.getModifiers into "BUTTON1_MASK", "BUTTON2_MASK" and "BUTTON3_MASK"

Similar Messages

  • Allow right-click selection in a JTree

    Hi everybody! How are today? Fine? I hope so.
    I've got a little question about JTrees: i want to put a right-click popup menu on my JTree, which may not be the same depending on which node of the tree is selected.
    My problem is that i must do a left click selection of the node before doing the right click in order that this one may be effective and correct (i.e the correct popup menu appears).
    So, i want to allow the right click selection in my JTree to select the node and to perform the action linked to the Popup menu.
    I will be very thankfull if someone could help me :)

    Sorry to post twice, but just thought i'd post the code to show you what I mean (forgive me not making this entirely generic):
    ///// Some "global" variables:
         private JPopupMenu               stPopupMenu;
         private TreePath               stPath;
         private String                    stPathComponent;
         private int                         stCount;
         private Object                    selectedNode;
    ///// Attaching the listeners:
    symbolTreeDisplay.addTreeSelectionListener(stHandler);
    symbolTreeDisplay.addMouseListener(stHandler);
    //// The event listener class:
         private class SymbolTreeHandler extends MouseAdapter implements
                   TreeSelectionListener
              public void mouseClicked(java.awt.event.MouseEvent event)
                   try
                        if (event.getModifiers() == event.BUTTON3_MASK)
                        {//right button click on mouse
                             stPopupMenu = new JPopupMenu();
                             // add your logic here, based on selectedNode to add items to the menu
                             stPopupMenu.show(symbolTreeDisplay, event.getX(), event
                                       .getY());
                   catch (Exception e)
              public void valueChanged(TreeSelectionEvent aTreeEvent)
                   try
                        stPath = aTreeEvent.getPath();
                        stCount = stPath.getPathCount();
                        selectedNode = stPath.getPathComponent(stCount - 1);
                   catch (Exception e)
         }

  • Right click select node in tree (for a standalone Air app)?

    For the sake of userfriendliness (in regard to a context menu) I wold like to "move" the selected node in a tree to the node that currently has the focus when right clicking it - like how the context menu access in windows file explorer works (focus and selected item are always the same  when right clicking).
    In worst case scenario I would like to disable a created context menu if the selected node and the node that currently has the focus are not the same).
    Now users can get confused when right clicking to access my context menu, in the tree structure, if the selected node and the node they are currently hovering over (and thus are in focus) are different.
    I was thinking of finding which node currently has the focus and then making that node the selected node - but I cant get it to work:-).
    Please, help a beginner.

    Hi,
    Duplicate thread of
    http://swforum.sun.com/jive/thread.jspa?threadID=64518
    MJ

  • Right click selection issue

    I am using HP Laptop with window 8.1.
    The right click button on the keyboard is not available so till the time I was using mouse for the right click.
    Now I install Hotkeys software & configure right Alt button of the keyboard as a right click button.
    It is working fine means whenever I clicked on the right Alt it is working as a right click, this is helpful in excel specially.
    But after this I am facing a new issue, this issue is when I using excel or word.
    When I move the cursor & select any cell with the mouse & then click on right alt it work properly.
    But after the selection from the mouse if I change the location by using arrow keys of the keyboard the location get changed but after changing the selection when I click on right Alt button the right click options open for the cell which was selected by
    the mouse.
    Hope it is clear.
    Example- If I select A5 location in excel by mouse & then goes right with keyboard right click on C5 location, the selection goes to the desired location, but if now I click on right Alt to open the options the cursor automatically opened the properties
    of A5 instead of C5.
    Here I clicked by mouse on A5 & moves to C5 by keyboard.
    Please help.
    This is  not an issue of scroll lock.

    I am using HP Laptop with window 8.1.
    The right click button on the keyboard is not available so till the time I was using mouse for the right click.
    Now I install Hotkeys software & configure right Alt button of the keyboard as a right click button.
    It is working fine means whenever I clicked on the right Alt it is working as a right click, this is helpful in excel specially.
    But after this I am facing a new issue, this issue is when I using excel or word.
    When I move the cursor & select any cell with the mouse & then click on right alt it work properly.
    But after the selection from the mouse if I change the location by using arrow keys of the keyboard the location get changed but after changing the selection when I click on right Alt button the right click options open for the cell which was selected by
    the mouse.
    Hope it is clear.
    Example- If I select A5 location in excel by mouse & then goes right with keyboard right click on C5 location, the selection goes to the desired location, but if now I click on right Alt to open the options the cursor automatically opened the properties
    of A5 instead of C5.
    Here I clicked by mouse on A5 & moves to C5 by keyboard.
    Please help.
    This is  not an issue of scroll lock.

  • Bug in right click selection in reports

    Build 22.71, on Linux and Windows.
    When I go to, for example, the sessions report, and right click on a row which I want to invoke a trace session command on, the whole column where I right clicked get selected, so it does not correctly indicate to the user which session will have trace enabled on.

    Add mouselistener:
    MouseListener ml = new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
             if (SwingUtilities.isRightMouseButton(e)) {
               doSomething();
          }//mousePressed
          public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
              doSometing();
          }//mouseReleased
        };//mouseListener
        myList.addMouseListener(ml);

  • Stopping right click selecting tab in JTabbedPane

    Hello all,
    This may be a really simple thing + I'm probably being thick, but is there a way to prevent a right click changing the selected tab on a JTabbedPane.
    I tried consuming the MouseEvent, but that didn't seem to work. Couldn't find an answer anywhere else in the forums & couldn't see anything in the JavaDoc that looked as if it would help.
    Answers on a postcard please......
    RT

    You might be able to extend JTabbedPane and override setSelectedIndex().
    I had to do this to work around a focus issue I had.
      This class extends JTabbedPane to correct a problem where it doesn't
      request focus when clicked on.
    import java.awt.*;
    import javax.swing.*;
    public class MyJTabbedPane extends JTabbedPane {
      public void setSelectedIndex(int index) {
        Component comp = KeyboardFocusManager.
            getCurrentKeyboardFocusManager().getFocusOwner();
        //  if  no tabs are selected
        // -OR- the current focus owner is me
        // -OR- I request focus from another component and get it
        // then proceed with the tab switch
        boolean noTabSelected = getSelectedIndex()==-1;
        boolean hasFocus = requestFocus(false);
        boolean compIsMe = comp==this;
        if(noTabSelected || hasFocus || compIsMe) {
          super.setSelectedIndex(index);
    }

  • Right click select all?

    Hi, Is there an easy way to add a select all command to the contextual menu when you right click/ctrl click in the finder?
    I've tried some v complex apps & had no success.. Thanks.

    Welcome to Apple Discussions.
    There is a free utility called, OnMyCommand which can do this...
    http://www.macupdate.com/info.php/id/9283/onmycommand
    There's also the ⌘ -a keystroke.
    -mj

  • Right clicking selection gives nothing

    So to make this short, I can use the pen tool to create a shape, then by right clicking it I can decide what I want to do with it. When I click "Make selection" I've selected the shape, but when I right click it again in order to find out what I want to do with that shape, it doesn't let me do anything. Everything grayed out. Normally I'd have the option to copy to layer or copy to cut but nothing.
    Looks like this

    I can see that you have made a shape with the Pen tool.  You have right clicked and cosen Selection, but you must have specified a high Feather value because the selection only covers a small part of the shape, (the matching ants indicate 50% opacity). 
    From there, you would take other routes to achieve what you mention.  Ctrl j would copt the selection to a new layer, for instance, but that layer will have a heavily feathered outline.   You should still have some options if you right click again, but useful as right clicking can be, it doesn't cover everything.

  • Right-click/select on trackpad not working

    Hi
    Basically the "right click" option on my trackpad has stopped working, I can't highlight sections of text or images, can't click and drag any items and can't resize windows or images. I'm going crazy does anyone know what's wrong? I called Apple and they didn't really help with anything, I've reset my preferences to default but no luck!
    I can scroll with two/three/four fingers fine it's just when I want to click with two that nothing happens.
    Any help would be greatly appreciated!
    Alyssa

    01/04/14 Update:  I've updated all SW (BIOS, UltraNav Driver and Utility, latest Win7 updates) but right button still won't work.  Ran the PC Doctor diags for the UltraNav and it shows the right button highlighted constantly (as opposed to it blinking on/off when button is processed like the the left button does).

  • Out of the blue, unable to open Word attachment in Mail with double click. Have to Right click, open with, select Microsoft Word. Am running Snow Leopard and Microsoft Office for Mac 08. Cheers

    Out of the blue, am unable to open Word attachments in Mail with the usual double click. (Get a longwinded error message)
    Need to right click, select open with, and select Microsoft Word. Have been using Microsoft Office for Mac 08 for years.
    I have reinstalled the Office software. A couple of tech people have been unable to fix it. Any suggestion?? debsuemy

    Please re-post in the Office for Mac Product Forums .

  • Acrobat 11 Pro - problem with right-click "Convert to Adobe PDF" output folder

    I'm migrating from one machine running Windows XP Pro with Acrobat 8 Pro to Windows 7 Pro with Acrobat 11 Pro.
    On the XP machine, when I right-click on a document and select "convert to Adobe PDF" the process works just fine - it always outputs the file to the target destination I have set in the Adobe PDF printer definition.
    On the Windows 7 Pro/Acrobat 11 Pro machine, the exact same settings are ignored: the PDF will always end up in the same folder as the source file.
    Both the source folder and the destination folder are on one of my office's networked drives.
    Under the Printing Preferences, I have the output folder address set the same on both machines, so it *should* go to the right location on the new machine.
    Oddly enough, on the Acrobat 11 Pro machine, if I select Adobe PDF as the default printer and do a test print, it *does* print to the correct folder!
    This has got me stumped!
    Thoughts?
    (update from later in the day)
    If Adobe PDF is selected as the default printer, I *can* select a bunch of documents, right-click, select "print", and Word will open up, and they'll print to the correct target folder.
    So, it's "just" the right-click "Convert to Adobe PDF" that doesn't work correctly.

    The reinstall is typically the last ditch effort to do. The first step is Help>Repair and Help>Updates. As far as Office 2013, the PDF Maker of AA X is not compatible and you can only print. In your list of errors it showed a problem with AcroTray.exe. As a first step, go to the print and select print-to-file. The file will be a PS file (maybe with a PRN extension). Once the printer if finished, open the file in Distiller to complete the process. If that is successful, then the problem is with AcroTray. Check your running tasks to be sure AcroTray is indeed running. If not, that is likely the problem. If it is, then restart it (it is located in the Acrobat folder). AcroTray provides the interface between the PS creation and Distiller to automate the process of creating the PDF.

  • How to get a pop-up menu on right click of JTree?

    hi
    My application consists of a JTree.I am having a 2 root nodes each one have some child nodes.in the first root node what i want is on right click of child node i have to display one option that is enabled and on the second root node what i want is on right click of child node i have to display one option that is disabled..
    how to do that
    thanks for your reply in advance,

    When you are creating your nodes, do node.setUserObject(objectName);
    and on right click, do something like this
    if (e.isPopupTrigger() == true) {
             selPath = tree.getPathForLocation(e.getX(), e.getY());
          try {
             // If Right Click, Select the Node
             Object[] selectedPath = selPath.getPath();
             DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedPath[selectedPath.length - 1];
             try {
                dataObject = (MyObject) selectedNode.getUserObject(); // Set the Data Object
             } catch (ClassCastException ex) {
                                      ex.printStackTrace();
             // Check for the right click on Framework Node
             if (dataObject.getClass().isInstance(new MyObject()) == true) {
                // Disable the pop-up menu
    ....

  • Right-click multiple JTable rows at once?

    Hi everyone,
    Haven't posted for a while but I've been trawling through Google and these forums looking for anyone who has implemented a JTable that allows the user to right-click multiple rows after selecting the multiple rows with a left-click. Currently the JTable allows multiple rows to be selected (MULTIPLE_SELECTION policy enabled) yet when you right-click on any of the highlighted rows it only right-clicks on the one out of the group you happened to click on and deselects all the other previously selected rows. Does anyone know of a way of enabling the right-click of multiple items (new listener or just a simple parameter change?)
    Any help would be much appreciated.

    I just have a mouse listener which, on a right-click, selects the row if it's not currently selected and does nothing if the row is already selected; then pops up the menu.

  • Right click on datagrid question

    Hi guys
    I'm trying to get the columnIndex on a right click on a datagrid, so that I can use it when I select an item from my custom contextMenu.
    Currently...
    data_grid.addEventListener(ListEvent.ITEM_ROLL_OVER, dataGridRollOver);
    private function dataGridRollOver(event:ListEvent):void    {  lastRollOverRow = event.index;  lastRollOverColumn = event.columnIndex; }
    Then in my contextMenu function, I use lastRollOverRow and lastRollOverColumn
    It works fine if I right click, select a contextMenu option, then choose another row and repeat etc...
    However, say I right click, decide I've clicked on the wrong column, don't choose anything from the contextMenu, and then my next action is to right click on the correct column - the above event listener doesn't fire again (I presume because the contextMenu has focus), so my vars don't get updated.
    Is there a way to give focus back to the DG on a consecutive right click before re-displaying the contextMenu?
    I notice I don't need to set up an event listener to catch the right click for the datagrid's contextMenu. Is there something I can change so I can do something first before the contextMenu pops up?
    Cheers for your help.

    I'm a little confused mate. I thought that was what I already had set up (I forgot to mention that when the datagrid's RIGHT_CLICK function is triggered, I make sure the menu appears a few pixels left and up so that the mouse is over it), but are you saying that during creation, I need to apply a one-off event listener to the grid to initialize things as well as the one I already have that is listening to see if the user rolls off the entire grid:  rightClickMENU.addEventListener(MouseEvent.MOUSE_OUT, rightClickMenuRollOff); ?
    Re-reading my post, maybe I was a bit tired writing it!!!  Let me explain a little more clearly:
    - mainClass (where my datagrid is) calls and creates new instance of rightClickMENU, then calls a function to do this:
    addChild(rightClickMENU);
    rightClickMENU.visible = false;
    rightClickMENU.addEventListener(MouseEvent.MOUSE_OUT, rightClickMenuRollOff);
    (rightClickMENU class creates a container movieclip, then a bunch of rollover buttons, and addChilds each button to it's container - so the container is in the rightClickMENU class)
    - in mainClass, put this listener on datagrid: rightClickMENU.addEventListener(MouseEvent.MOUSE_OUT, rightClickMenuRollOff);
    - in mainClass, my roll on /roll off functions do this:
    private function showRightClickMenu(event:MouseEvent):void
                var X = event.localX * 4.3015;//default DG width is 272.  So set up correct right click position ratio 1170/272 = 4.3015.
                var Y = event.localY * 2.2513;//default DG height is 191    
                //with my datagrid pos offset, the coords below end up showing the menu with the mouse about three pixels in from the top corner:
                rightClickMENU.x = X+13; rightClickMENU.y = Y+75;
                rightClickMENU.visible = true;
    private function rightClickMenuRollOff(event:MouseEvent):void //menu roll out
                rightClickMENU.visible = false;
    Can you please explain a little more what you mean in your post?

  • No Right-Click or Two-Finger Scroll in Boot Camp

    I have had an odd problem. It looks like others are seeing this too, but I wanted to record my observations.
    Recently I have begun to notice that after booting into Windows 7 Pro (64-bit), I will briefly have two-finger right-click and two-finger scroll capabilities, but then these just go away. I have tried deleting the trackpad drivers that came with Boot Camp 3.2 per what I have seen on other threads, but that makes no difference. I also downloaded and reinstalled Boot Camp 3.2/64-bit; again, no difference.
    If anyone has any ideas, I would be happy to entertain them. Thanks!

    Ok this situation appears resolved on my MBPro so here is my handy guide.
    1) Visit Apples Product Support Page and Download this AppleBCUpdate Windows Executable
    http://support.apple.com/kb/DL874
    a) Download AppleBCUpdate.exe
    2) Visit RarLabs and Download a Shiny New Binarry of WinRAR (Demo/ShareWare)
    a) http://rarlabs.com/download.htm
    b) Be sure to get the Latest WinRAR 64x Version
    3) Visit your AppleBCUpdate.exe download location and Extract the Internal Driver Files (NOTE: This APP Will NOT Execute on a Windows 7 x64 Machine simply use WinRAR to UNARCHIVE)
    a) Right-Click AppleBCUpdate.exe, Select Extract Files Here
    b) Navigate to the New Foldier Created by WinRAR's Unarchive of AppleBCUpdate.exe (P.S. It should be named 'AppleBCUpdate')
    c) Locate AppleMultiTouchTrackPadInstaller64.exe
    * Right-Click this program and also Extract Files Here (that is use WinRAR to unarchive)
    d) Navigate to 'AppleMultiTouchTrackPadInstaller64'
    * See the Lovely Driver Files??? :B
    4) Perform a Manual Install of the AppleMTP64 (This is your working x64 Multi-Touch TrackPad Driver)
    a) Visit StartMenu->Computer
    b) (Right-Click) Select 'Properties'
    c) Select 'Device Manager'
    d) Select the 'Human Interface Devices" Tab
    * Target -> "Apple Multitouch" driver
    * Note: This Driver may say something similar like: "Apple Touchpad"
    * Tip: Make Sure it is NOT: Apple Keyboard, Mouse, IR Receiver, Wireless Mouse, Bluetooth Controll Receiver, or any of those other 'HID-Compliant Devices'
    * Once you have Determined Your Driver the -FUN- Begins
    5) Select 'Update Driver'
    a) Use the "Browse My Computer For Software" option (Manditory)
    b) Select "Let Me Pick a List of Drivers for My Software" (Or whatever it says)
    c) Select "Have Disk" Button and Point to the Location of "AppleMTP64"
    * This driver means "Apple Multi Touch Pad 64" NOTE: Do not use AppleMTM64 as that is a Mouse Driver (..and using that driver is an erronius procedure )
    d) Once the Driver is Loaded "Apple Multitouch" should be listed as a compatable Driver.
    * This is the Updated Version of the Best Working Driver
    6) Reboot and Enjoy
    ATTN: I belive this problem is cause by two Factors
    1) Apple did not build an Executable for Updating Windows 7 64bit with ApplePCUpdate 1.1
    * You have to extract all the special files to get it to work
    2) Window 7 'as-cool-as-it-might-be' does not always utalize the 'Best' Driver for your system, as so prevailantly obvious for their systems.
    ALSO:
    Visit: http://support.apple.com/kb/DL1066 to Update your MultiTouch TrackPad for MacOSX (it may help)
    Above all I have tested this workaround a little bit and it appears to be working pretty good. ("p)

Maybe you are looking for

  • How do I get my e-mail address into my profile

    I click on options (then wait a very long time) My email is shown as null. I follow the click here link to update it but get a box asking me if I am a new user, and the email requires a password, I don't understand why. If I enter a password and my e

  • Ipod cannot be updated to version 1.2 due to use by another application

    Keep on getting error in trying to update Ipod to version 1.2 (I have have Itunes 7.0 and Ipod version is 1.1.2). Says "it contains files that are in use by another application". Also tried restoring, etc and same error: "Ipod cannot be RESTORED beca

  • Employee Vendor Account Mismatch

    Hi, Wrong Employee Vendor accounts have been crated. For Ex, Employee  Vendor A/c 101 - Mr.B            100 - Mr. A 102 - Mr.C            101 - Mr.B 103 - Mr.D            102 - Mr.C (code} Actually it should like, Employee  Vendor A/c 101 - Mr.B     

  • How to write multi row sub query with the row containing range of values?

    Hi all, I have to include a column which contains weight ranges and it should come fom table called "report_range_parameters" The following query will reutrn those weight ranges. select report_parameter_min_value || ' -> ' || report_parameter_max_val

  • EJB 3.1 Lite Features Async,Timers ?

    Hi I was using glassfish 3.0.1 ,EJB 3.1 timers and async methods were working (in gfish 3.0.1). Now we are moving to glassfish 3.1, And I'm getting following error with EJB 3.1 lite web application. java.lang.RuntimeException: Invalid application. EJ