public static void onPopup(final JTextComponent comp, final F1<Range,JPopupMenu> menuF) {
    	comp.addMouseListener(new MouseAdapter() {
            public void mouseReleased(MouseEvent e) {
                if (e.getButton() == MouseEvent.BUTTON3) {
                	int start = comp.getSelectionStart();
                	int end = comp.getSelectionEnd();
                	
//                	System.out.println(start);
//                	System.out.println(end);
                	
                	// -1 because of JTextEditor
					JPopupMenu menu = menuF.e(
							comp.getClass().equals(JEditorPane.class) ?
							new Range(start - 1, end - 1) :
							new Range(start, end)
							);
					
					if (menu != null) {
						menu.show(comp, e.getX(), e.getY());
					}
                }
            }

        });
    }