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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…