• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

tracing mouse button click (left-middle-right)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I am using mouse listener interface in a simple java applete. I could trave all the mouse events, eg. the click event. But I want to trace which button is pressed, eg. left - middle - right
how can i trace the button from click event. Is there any 1 who can help me out. Thanks in advance

Sanjay
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use the method getModifiers():
public void mousePressed(MouseEvent e) {
if(e.getModifiers()==InputEvent.BUTTON1_MASK) {
System.out.println("Left button");
}
if(e.getModifiers()==InputEvent.BUTTON2_MASK) {
System.out.println("Center button");
}
if(e.getModifiers()==InputEvent.BUTTON3_MASK) {
System.out.println("Right button");
}
}
 
Whatever. Here's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic