Java JPopupMenu showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)

Here you can find the source of showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)

Description

Displays a popup menu.

License

Open Source License

Parameter

Parameter Description
menu the menu to show
invoker the invoking component
e the absolute positions on screen of the event are used

Declaration

public static void showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e) 

Method Source Code

//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);
    }
}

Related

  1. showPopup(JPopupMenu popup, MouseEvent event)
  2. showPopupCloseMenu(JPopupMenu popup, Component parentComponent)
  3. showPopupMenu(final JPopupMenu popup, final Component component, int x, int y)
  4. showPopupMenu(javax.swing.JPopupMenu popup, Component comp, int x, int y)
  5. showPopupMenu(javax.swing.JPopupMenu popup, Component comp, int x, int y)
  6. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  7. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  8. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  9. showPopupMenu(JPopupMenu popup, Component comp, int x, int y, boolean point)