JPopupMenu の isPopupTrigger2008年10月12日 09時42分01秒

PhotoView v1.0 の右クリックが Windows 上で、正しく動作しないのに気が付いた。調べてみると、「MouseEvent の isPopupTrigger を使って、JPopupMenuだすというふうにコードを書いていて、osx と windows で注意しないといけないことです。」に解決策がある。

Windows では、mouseReleased でのみ isPopupTrigger が true を返すみたいだ。Mac OS では mousePressed と紹介されている。どうも、FreeBSD 等も含めた UNIX 系の OS 全般に言えるようだ。

さて、これ以外の場合もあるのかと不安になっていたら、Java API の以下のように記述されていた。

Note: Popup menus are triggered differently on different systems. Therefore, isPopupTrigger should be checked in both mousePressed and mouseReleased for proper cross-platform functionality.