Solved

About MouseListener

Posted on 2001-07-06
4
183 Views
Last Modified: 2011-10-03
How can I respond to the event of clicking with the RIGHT button of the mouse.

I already have a MouseListener set up, but the MouseEvent it give me does not have any means to find out if the user clicked with the right button or with the left button.

Any way to do this?????????????

Thanks in advance.
0
Comment
Question by:dyma82
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
rkenworthy earned 50 total points
Comment Utility
Source code from javax.swing.SwingUtilities:

    public static boolean isRightMouseButton(MouseEvent anEvent) {
        return ((anEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK);
    }
0
 
LVL 4

Expert Comment

by:kylar
Comment Utility
Also, if you want to make a popup menu there is always the isPopupTrigger() call.

Cheers,
Kylar

0
 
LVL 5

Expert Comment

by:Netminder
Comment Utility
0
 
LVL 5

Expert Comment

by:Netminder
Comment Utility
Admin notified of User neglect. Force-accepted by
Netminder
Community Support Moderator
Experts Exchange
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now