Right clicking in Java

Is there a mouse event in java for right click?

There is no separate method to do that. But you can do something like this. Hope this help.
public void mouseClicked(MouseEvent e){
if (e.getModifiers() == InputEvent.BUTTON3_MASK)
System.out.println("right CLicked");
else{
System.out.println("left CLicked");
}

Similar Messages

  • Right click context menu does not appear only for Java 1.7, AWT TextField

    I have been debugging some issues that an application has been having with Java 1.7 versus older versions. A new problem I have encountered is that the right click context menu does not function in any TextField. It works fine when running/compiling it with any previous version of Java. I have tried coding a simple test with a Frame, Panel and TextField to see if it might be something else in the more complex application that was causing it, but the simple test class has the same problem.
    I have searched for other people having the same issue, but I have not found anything comparable. This seems like a huge change from one version to the next and I am surprised that I am not finding this mentioned anywhere else. Can someone point me to anything that discusses this issue that I am having? Does 1.7 require I implement my own context menu? I realize AWT is old technology, but this is an old, fairly complex application that doesn't use swing, and that is not going to change at this point.
    My simple test:
    import java.awt.*; 
    import java.awt.event.*; 
    import java.util.*; 
    class testF3 extends Panel 
      public static void main(String args[]) 
        Frame f = new Frame(); 
        Panel p = new Panel(); 
        f.setLayout(new BorderLayout()); 
        f.add("North", p); 
        TextField tf1 = new TextField("", 20); 
        p.add(tf1); 
        Dimension medm = f.getSize(); 
        medm.height = 100; 
        medm.width = 200; 
        f.setSize(medm); 
        f.setVisible(true); 

    In the past few days since upgrading to 4.0.4, the entire right-click context menu for links is gone and replaced with one item: "Copy Link" The "Open In New Tab" item, along with some other context items, is no longer there.
    That's actually a problem with your particular installation of Safari, b. I've got all the contextual menu entries with my 4.0.4.
    I helped fix one of these recently here at the forum. Try the procedure from the following post (it got back Tho's missing contextual menu entries):
    http://discussions.apple.com/thread.jspa?messageID=10598385&#10598385

  • Right click function in Java applet...

    Hello, how's it going? I'm currently working on getting a pocket pc to load java applets through a web browser. I am currently using Netfront 3.0 for my browser and it contains JV-Lite 2 as its JVM. The applet loads and is functional. However, I am having issues with 'right clicking' functions. This particular applet is used as an interface for a building automation controller and it is necessary for right clicking to function (there are menus specific to functions that can only be accessed by right clicking). What are my options for fully functional java in a pocket pc web browser? Any help would be appreciated.
    Take care!

    RIGHT CLICK FACILITY:
    public void mouseClicked(MouseEvent event){
    if((event.getModifiers() & event.BUTTON1_MASK)!=0)
    //left clicked actions
    elseif((event.getModifiers() & event.BUTTON3_MASK)!=0)
    //right clicked actions

  • Web Dynpro Java UI Customization from Portal Using CTRL+Right Click in Prev

    Hi Team,
    I am able to hide some Web Dynpro UI elements from Portal Content Administration >> Web Dynpro iView >> Preview and by Pressing CTRL+RIGHT CLICK.
    Here I need to understand the concept like how things work in this case. If we hide some UI in Web Dynpro Java iView customization will there not be any RFC/BAPI calls associated with that particular UI
    For Example: Web Dynpro iView is made up of CompA and CompB and I am going to hide the UI associated with CompA. When I invoke the application will there not be any activity like invoking CompA calling associated RFC/BAPI etc related to CompA
    Please help me in understand the concepts and performance implications on this.
    Regards
    Sudhir

    Hi Sudhir
    You are quite right to raise this concern
    If you start hiding elements you may find a change to functionality
    For example - in ESS - if you hide a field that is set to mandatory in the back-end ECC when the user
    goes to edit the screen they will not see the field and not maintain the field but they will get an error
    "fill in all required fields" - which will completely confuse them as they will have filled in all displayed fields
    Also if you hide one field in ESS that is required to populate another field this too many causes inconsistencies or errors
    Ideal UI elements to hide are those that have been set to unsued (in the case of ESS in the back-end) and have no dependancies to other fields - however there is no complete list - you must test each scenario to your satisfaction
    Best wishes
    Stuart

  • Portal iview Customization for Webdynpro Java CTRL+ Right Click in Preview

    Hi Team,
    I am able to hide some Web Dynpro UI elements from Portal Content Administration >> Web Dynpro iView >> Preview and by Pressing CTRL+RIGHT CLICK.
    Here I need to understand the concept like how things work in this case. If we hide some UI in Web Dynpro Java iView customization will there not be any RFC/BAPI calls associated with that particular UI
    For Example: Web Dynpro iView is made up of CompA and CompB and I am going to hide the UI associated with CompA. When I invoke the application will there not be any activity like invoking CompA calling associated RFC/BAPI etc related to CompA
    Please help me in understand the concepts and performance implications on this.
    Regards
    Sudhir

    Hi Sudhir,
    Great Question! :-)... I am not 100% sure, but my guess would be that you would still see the associated BAPI/RFC calls since the "hiding" of the fields is purely a UI feature done using the Portal PCD.
    However you can of course test this for your scenario, by running an RFC trace for your user in the ECC system and then run the WDJ application and see if you see the RFC calls or not (more or less depending on the hidden/visible status of your component).
    Hope that helps,
    Simon

  • Launching java program via windows right click

    I've written a Java Applicaton to display some data files we get from our cash registers. The app is stored in a jar file, with a manifest file. Double-clicking the jar file runs the program. Then we can select open from the file menu adn open our data files.
    What I would like to add is the ability to right-click a data file in Windows, have the Java app appear in the Open With... menu in the popup menu, and then have windows launch the jar file.
    I understand I would have to change the program to accept a parameter, and I know how to do that from the command line.
    Is it possible to add a jar file to the popup menu in windows, and pass the path of the file into the main class in the jar file?
    I did some Google searches this morning but couldn't find anything.
    Thanks
    Bill

    Well purely speaking no. But then you can do most anything you like if you are clever with C++ and JNI.

  • Invoke Java app on file right clicks

    Hi,
    Can i have my java desktop app. to be displayed in the OS Pop-menu options, i.e i want them to appear on right clicks of a file similar to options like "copy, cut, send to, etc.". Is there a way to do this. Can anybody suggest me in this.
    I am working on Fedora 4 and using JDK1.6
    Thanks
    Paul.P

    This would be different for each operating system. You need to learn how your operating system works regarding these shortcuts. There's nothing here or in Java that will help you.

  • Right clicking no longer works in Java?

    Control clicking in Java no longer works on my new powerbook. Other applications seem to be fine.
    How do I correct this? If uninstalling and reinstalling Java is the answer, how do I do this. I have poked around a bit but cannot find an answer to this.

    Use the command key.

  • When I Shift Right Click, I get a java error pop-up. FF 4.0

    If I use the Shift Right click to open a link in a new window I get a pop-up error screen. If I close that pop-up my link opens OK on a new window
    Using FF 4.0 Mazilla Firefox Yahoo! Edition
    yahoo - 1.8

    A few hidden preferences to check to make sure that the jump lists are enabled:
    # Type '''about:config''' into the location bar and press enter
    # Accept the warning message that appears, you will be taken to a list of preferences
    # In the filter box type '''browser.taskbar.lists''' this should bring up a few preferences
    # To enable all parts of the jump list, make sure the following preferences are set to '''true''', if they are not double-click to them to change their value
    ## browser.taskbar.lists.enabled
    ## browser.taskbar.lists.frequent.enabled
    ## browser.taskbar.lists.recent.enabled
    ## browser.taskbar.lists.tasks.enabled

  • Touchgraph link browser right click won't work; jre 1.4.2_03 linux

    touchgraph link browser right click won't work; jre 1.4.2
    Wanted to mention that the touchgraph link browser(java client) client starts correctly in Redhat 9, but i found one problem when trying to edit links. The problem being that I can't open the small popup menu when i right click in linux RedHat 9. left clicking while dragging on a selected link (in edit mode) lets you create a new link both in microsoft windows 95a and in Redhat 9. When i right click in win95a, a small menu appears that allows me to edit a link, but this menu doesn't appear after right clicking a link in edit mode in redhat 9 (which does work with TG link browser in win95).
    I tried using a 2 button mouse with 3 button emulation. I also tried to use a 3 button logitech trackball which works with the old logitech c7 setting in Redhat. I also tried to operate the mouse with it's three buttons using the number keypad in linux, which works in other applications under linux. The same problem still happens in trying all of these methods.
    I was told that unix and windows use different "select," "extend," and "menu" buttons(in relation to the mouse).
    Maybe, microsoft windows is using a different method of interpreting the right mouse button than redhat linux 9. if so, maybe there is a way to do this in linux (really, i have no idea how this could be done, but am open to try).
    If there is a solution, i would appreciate knowing how to go about doing it. .
    note: I am using Sun's java 1.4.2_04 in windows 95a and I am using Sun's java 1.4.2_03 in Redhat 9. Both are the most current, i just downloaded them recently.
    note: touchgraph link browser is an open source java client and applet under the GNU general Public License. I think that the source code was included with the binary. I am using touchgraph link browser v 1.20 . I downloaded from sourceforge.net
    in google i found the following:
    https://lists.xcf.berkeley.edu/lists/advanced-java/1999-September/000532.html
    note: mara, you helped me before when i was practically installing redhat 9 and i had a problem with the installation and you mentioned that it was a faulty cd-rom drive. with your help, i am enjoying in learning about linux for the past 5 months since your answer helped me install redhat 9 successfully. Thank you very much since my very first question to you.
    Answer Hello,
    I downloaded the program and, if I think of the right situation, the right-click doesn't bring a menu for me. The thing I noticed is that when I drag a new link and (with left mouse button pressed) press right button it has an effect of 'canceling' the link. That's why I think that right mouse button works correctly. The problem is why the menu does not appear.
    I can see two reasons, both causing problems not easy to solve: bug in the program or incompatibility between Windows and Linux java versions. The second one should not happen.. but it doesn't mean it's impossible. A bug in the program should be easier to find, but not by me (with not very big Java experience it'd take me several days).
    What I'd do in your place is to mail the program developers (or report a bug). It won't make things worse, but can fix things.
    Sorry that I can't help more
    Mara
    notethe second half is a post i made to all experts.com

    http://www.realvnc.com/pipermail/vnc-list/2001-February/020570.html
    this Url has a comment on this problem in linux. just wanted to post this. it might help.

  • An internal build error has occurred. Right-click for more information

    Greetings!
    We are using Eclipse 3.4 or 3,5 with Flash 4 plugin and Flex SDK 3.3.0.
    Project set comprises several, more than a couple dozen, dependent  Flex and Java projects.
    Time-to-time we run across an internal build error on all Flex projects.
    The stack trace where topmost entries are:
    So far we did not find how to get around the problem except delete project set and start from
    scratch.
    Pleas help!
    !ENTRY com.adobe.flexbuilder.project 4 43 2010-07-23 14:40:38.353
    !MESSAGE Uncaught exception in compiler
    !STACK 0
    java.lang.NullPointerException
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASBuilder.applySettings(ASBuilder.java:3 25)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASApplicationBuilder.setup(ASApplication Builder.java:67)
    at com.adobe.flexbuilder.multisdk.compiler.internal.ASItemBuilder.setup(ASItemBuilder.java:5 4)
    at com.adobe.flexbuilder.project.compiler.BuilderFactory.createBuilder(BuilderFactory.java:8 0)
    at com.adobe.flexbuilder.project.compiler.BuilderFactory.createBuilder(BuilderFactory.java:5 9)
    at com.adobe.flexbuilder.project.compiler.BuilderManager.getBuilder(BuilderManager.java:192)
    When it happens you can not open project "Properties | Flex Compiler"  dialog because error
    message pops up saying "The currently displayed page contains invalid values."
    I am not sure how "an internal build error..." relates to "...displayed page contains invalid values"
    but  it worth to mention anyway.
    Thanks for your help.

    Getting the same error and deleting bin-debug files doesn't help. All switch statements have a case so that isn't an issue either.
    Says to right click on the error for more info but that brings ups broken webpage.
    Adobe I think you really rushed Flash Builder out to fast.  These weird errors and the namespace debacle is just totally unprofessional.

  • BW Error on Portal, Right Click gets (Internet Explorer) Menu

    Hi Experts,
    Our Netweaver Portal is 2004s. There is BW system also in the landscape whose reports are fetched and displayed on the portal. I get the errors when I navigate to (Role) -> GroupReports (Workset) -> Cockpit - > Customer Projects -> Plan Cost Quality -> Market Unit.
    Now when I click on Market Unit (in detailed Navigation), its generates a Chart (Image) in the content Area which has many Market Units on the screen. From the list of Market Units in this Image I select any Market unit then Right Click on "Market Unit"- >GoTo-> Projects : Plan Cost Quality by Company. (This right Click gets me BW TYPE of options for DrillDown etc).
    It processes and gets me the Name of the Market unit in the NAVIGATION BLOCK. In this Navigation Block, if I right Click on "BUYING CUSTOMER", it gets me a Internet Explorer (Right Click) Menu (with options like OPEN, OPEN IN NEW WINDOW, SAVE TARGET AS..., PRINT TARGET etc ) and not a BW iView Menu that allows me facilities like DRILL DOWN etc.
    There are these JAVA SCRIPT ERRORS at the bottom of the browser (left Side - with a message "Done but with errors on page"), when this page is loading after I do Right Click on Market Unit"- >GoTo-> Projects : Plan Cost Quality by Company.
    Following are the Java Script Errors in order of NEXT:
    1. 'SAPBWJSgdo' is null or not an object
    2. Permission Denied.
    Plz suggest what needs to be done to resolve this issue.
    Regards
    Saurabh

    The note 783496 addresses your issue.

  • Why can't I right-click to save images from webpages with FF 3.6.13?

    Ever since I updated my FF version to 3.6.13, I find I have trouble saving images from websites. And not just on specific websites, but everywhere (and they aren't protected or anything from saving). In the past I could right-click on them and do "save as..." Now the only option I have is "save link as..." Whenever I click on this, nothing at all happens. Is this a bug with version 3.6.13? It's really annoying.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    * [[Troubleshooting plugins]]
    There are other things that need attention:
    Your above posted system details show multiple Java Console extensions.<br />
    You can uninstall (remove) the Java Console extensions and disable the Java Quick Starter extension, you do not need them to run Java applets.
    See http://kb.mozillazine.org/Java#Multiple_Java_Console_extensions
    Disable the Java Quick Starter extension: Tools -> Add-ons -> Extensions<br />
    Control Panel -> Java -> Advanced tab -> Miscellaneous -> Java Quick Starter (disable)
    See http://www.java.com/en/download/help/quickstarter.xml - What is Java Quick Starter (JQS)? What is the benefit of running JQS? - 6.0

  • Select multiple nodes in a JTree a right click

    Hi all,
    I've a JTree and I'd like to allow the user select some nodes (one or more) right click and than show a popupMenu.
    This behavior seems not to be easy, because if I select a single node (right clicking on it) the node does not appear selected ; I need to select it left clicking and than everything works fine.
    I read some posts found in the forum and the solution seems to be :
    - attach a mouseListener to the JTree
    - get the TreePath of the node selected
    - force the selection on the node with setSelectionPath(TreePath)
    This works fine if you need to select only one node, cause if you have to select more, you simply cannot.
    I wonder a so obvious behavior is so hard to achieve.
    I hope somebody out there had made the magic.
    Any help would be appreciated.
    Flavio Palumbo

    Hi Darryl,
    I wrote the test case below.
    Using the methods you suggested it works almost fine.
    The only behavior not desired is when you select a range (shift or control), release the key an than right click ; in this case remains selected the only node you clicked on ; to select the range clicking with the right button, you have to keep pressed the key.
    Any hint would be appreciated.
    Flavio
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.JFrame;
    import javax.swing.JMenuItem;
    import javax.swing.JPopupMenu;
    import javax.swing.JTree;
    import javax.swing.SwingUtilities;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreePath;
    public class TestTree {
        JTree jtr = null;
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new TestTree();
        public TestTree() {
            JFrame jf = new JFrame();
            jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            try {
                javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
                javax.swing.SwingUtilities.updateComponentTreeUI(jf);
            } catch (Throwable e) {
            jf.setPreferredSize(new java.awt.Dimension(200, 560));
            javax.swing.JScrollPane js = new javax.swing.JScrollPane();
            DefaultMutableTreeNode root = new DefaultMutableTreeNode("root");
            jtr = new JTree(root);
            jtr.addMouseListener(new TestTreeML());
            js.setViewportView(jtr);
            jf.getContentPane().add(js);
            for (int i = 0; i < 20; i++) {
                DefaultMutableTreeNode nodoFiglio = new DefaultMutableTreeNode("nodo" + i);
                ((DefaultTreeModel) jtr.getModel()).insertNodeInto(nodoFiglio, root, root.getChildCount());
            jf.pack();
            jf.setVisible(true);
        public class TestTreeML extends MouseAdapter {
            @Override
            public void mousePressed(MouseEvent e) {
            @Override
            public void mouseClicked(MouseEvent e) {
                try {
                    if (!e.getSource().equals(jtr)) {
                        return;
                    TreePath tpSel = jtr.getPathForLocation(e.getX(), e.getY());
                    if (tpSel == null) {
                        return;
                    int i = 0;
                    final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tpSel.getLastPathComponent();
                    TreePath[] tpExisting = null;
                    if (e.isControlDown() || e.isShiftDown()) {
                        System.out.println("control/shift");
                        TreePath[] tpEx = jtr.getSelectionPaths();
                        tpExisting = java.util.Arrays.copyOfRange(tpEx, 0, tpEx.length + 1);
                        i = tpEx.length;
                    } else {
                        tpExisting = new TreePath[1];
                    tpExisting[i] = tpSel;
                    jtr.setSelectionPaths(tpExisting);
                    if (e.getClickCount() == 2) {
                        System.out.println("double click on " + node.getUserObject());
                    if (javax.swing.SwingUtilities.isRightMouseButton(e)) {
                        if (!e.isControlDown()) {
                            jtr.setSelectionPath(tpSel);
                        JPopupMenu menu = new JPopupMenu();
                        JMenuItem it0 = new JMenuItem("Option1");
                        it0.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                System.out.println("Option1 on " + node.getUserObject());
                        menu.add(it0);
                        JMenuItem it1 = new JMenuItem("Option2");
                        it1.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                System.out.println("Option2 on " + node.getUserObject());
                        menu.add(it1);
                        menu.show(jtr, e.getX(), e.getY());
                } catch (Throwable t) {
    }

  • Right click is not working after upgrading to firefox 3.6.7

    Firefox updated today to 3.6.7. Now when I right click to same a page, or any other function nothing happens. Have gone to tools options, java script to disable menu changes. But nothing worked. Back to default.
    == This happened ==
    Every time Firefox opened
    == After upgrading to the latest version

    I cured mine by disabling ad block plus.
    This is a right shame because adblock plus is otherwise awesome..

Maybe you are looking for

  • Switching off location services disables cell service?

    Is this right? If I switch off location services, I cannot send or receive cell phone calls. Basically switching off location services is the equivalent of putting my phone in airplane mode? I'm using an iPhone 5 with the current iOS. Thanks.

  • WLS 10.3, JDeveloper 11- JDBC/JNDI

    I've been looking for a couple days now, and i can't find a understandable answer. I am trying to implement Security into my ADF application. I would like it to use Active Directory, (possibly from more than 1 AD server) or permissions based on there

  • Mail will not stay as default email reader

    I have the mysterious problem facing a computer newly installed MacBook Air 2012 with 10.8.2. It has Parallels, MS Office 2011, but no MS Mail Application. I have another account on this computer that is not affected by this issue. The issue is that

  • Parent Node syndication

    Hi, assume you have a hierarchy table with 2 hierarchy levels. Each record in that hierarchy table has a Name and an ID. I want to syndicate the second level (lowest level) of the hiearchy. For each second-level object there should be the name and th

  • How can I define same Price Conditions for two different Sales Deals ??

    I need to define for the same price condition, lets say ZPMP, two different values or condition records, for two different sales deals and the same valid dates For example, Sales deal 1, ZPMP equal to USD 15 and valid dates from 04/15/08 to 04/30/08.