1 4 package org.oddjob.designer.view; 5 6 import java.awt.event.MouseAdapter ; 7 import java.awt.event.MouseEvent ; 8 9 import javax.swing.JPopupMenu ; 10 11 14 class PopupListener extends MouseAdapter { 15 private JPopupMenu popup; 16 17 public void setPopup(JPopupMenu popup) { 18 this.popup = popup; 19 } 20 21 public void mousePressed(MouseEvent e) { 22 maybeShowPopup(e); 23 } 24 public void mouseClicked(MouseEvent e) { 25 maybeShowPopup(e); 26 } 27 public void mouseReleased(MouseEvent e) { 28 maybeShowPopup(e); 29 } 30 31 private void maybeShowPopup(MouseEvent e) { 32 if (popup != null && e.isPopupTrigger()) { 33 popup.show(e.getComponent(), e.getX(), e.getY()); 34 } 35 } 36 } 37 | Popular Tags |