1 19 20 package org.netbeans.modules.diff.builtin.visualizer; 21 22 import javax.swing.*; 23 import java.awt.event.MouseEvent ; 24 import java.util.List ; 25 import java.util.Iterator ; 26 27 32 public class DEditorPane extends JEditorPane { 33 34 private List popupActions; 35 36 protected void processMouseEvent(MouseEvent e) { 37 if (e.isPopupTrigger() == false) { 38 super.processMouseEvent(e); 39 } else { 40 if (popupActions != null) { 41 JPopupMenu popup = new JPopupMenu(); 42 Iterator it = popupActions.iterator(); 43 int actions = 0; 44 while (it.hasNext()) { 45 Action action = (Action) it.next(); 46 if (action == null) continue; 47 popup.add(action); 48 actions++; 49 } 50 if (actions > 0) { 51 popup.show(e.getComponent(), e.getX() - 7, e.getY() - 10); 53 } 54 } 55 } 56 } 57 58 public void setPopupActions(List actions) { 59 popupActions = actions; 60 } 61 } 62 | Popular Tags |