package org.springframework.richclient.util;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPopupMenu;

import org.springframework.util.Assert;

/**
 * @author Keith Donald
 */
public class PopupMenuMouseListener extends MouseAdapter {

    private JPopupMenu popupMenu;
    
    public PopupMenuMouseListener(JPopupMenu popupMenu) {
        Assert.notNull(popupMenu);
        this.popupMenu = popupMenu;
    }
    
    public void mouseClicked(MouseEvent e) {
        if (e.getButton() == MouseEvent.BUTTON3) {
            onAboutToShow(e);
            popupMenu.show(e.getComponent(), e.getX(), e.getY());
            popupMenu.setVisible(true);
        }
    }
    
    protected void onAboutToShow(MouseEvent e) {
        
    }

}
@@ -450,24 +450,29 @@
 %0A    %7D%0A    %0A
+    %0A
     public v
@@ -484,13 +484,13 @@
 ouse
-Click
+Press
 ed(M
@@ -516,47 +516,188 @@
     
-if (e.getButton() == MouseEvent.BUTTON3
+checkEvent(e);%0A    %7D%0A    %0A    public void mouseReleased(MouseEvent e) %7B%0A        checkEvent(e);%0A    %7D%0A    %0A    private void checkEvent(MouseEvent e) %7B%0A        if (e.isPopupTrigger()
 ) %7B%0A

use the isPopupTrigger() method