Here you can find the source of showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)
Parameter | Description |
---|---|
menu | the menu to show |
invoker | the invoking component |
e | the absolute positions on screen of the event are used |
public static void showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)
//package com.java2s; /*/* ww w . j a va 2 s . c om*/ * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import javax.swing.JPopupMenu; import java.awt.Component; import java.awt.event.MouseEvent; public class Main { /** * Displays a popup menu. * * @param menu the menu to show * @param invoker the invoking component * @param e the absolute positions on screen of the event are used */ public static void showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e) { showPopupMenu(menu, invoker, e.getXOnScreen(), e.getYOnScreen()); } /** * Displays a popup menu. * * @param menu the menu to show * @param invoker the invoking component * @param x the absolute X position on screen * @param y the absolute Y position on screen */ public static void showPopupMenu(JPopupMenu menu, Component invoker, int x, int y) { menu.setInvoker(invoker); menu.setLocation(x, y); menu.setVisible(true); } }