Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

java - How to detect right-click event for Mac OS

For windows and linux I am able to detect right click. But for mac I donot know how to detect right-click.

How to write java program to detect right click for Mac OS

Thanks Sunil KUmar Sahoo

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Instead of using MouseEvent.BUTTON3, a bettter self docummenting approach is to use

if (SwingUtilities.isRightMouseButton(event))
   // do something

Also, if you are using this code to display a popup menu, then you should not be using this approach since each OS has different key strokes to inovoke the popup menu. Read the section from the Swing tutorial on Bringing Up a Popup Menu.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...