Here you can find the source of setLocationOnScreen(JPopupMenu visibleMenu, int x, int y)
public static void setLocationOnScreen(JPopupMenu visibleMenu, int x, int y)
//package com.java2s; /*/*ww w .j av a 2 s . c om*/ * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ import javax.swing.JPopupMenu; import java.awt.Point; public class Main { /** * This method exists because popup menus can not be directly moved * (the have to be hidden and re-shown). */ public static void setLocationOnScreen(JPopupMenu visibleMenu, int x, int y) { Point invokerLocation = visibleMenu.getInvoker().getLocationOnScreen(); visibleMenu.setVisible(false); visibleMenu.show(visibleMenu.getInvoker(), x - invokerLocation.x, y - invokerLocation.y); } }