Java JPopupMenu maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent)

Here you can find the source of maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent)

Description

Check if the popup menu must be show and show it

License

Open Source License

Parameter

Parameter Description
e mouse event
menu a menu to show
parent a component for menu

Declaration

public static void maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent) 

Method Source Code

//package com.java2s;
/*//from  www.j  a va  2  s . com
 * This file is part of the VVIDE project.
 * 
 * Copyright (C) 2011 Pavel Fischer rubbiroid@gmail.com
 * 
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */

import java.awt.event.MouseEvent;

import javax.swing.JComponent;

import javax.swing.JPopupMenu;

public class Main {
    /**
     * Check if the popup menu must be show and show it
     * 
     * @param e
     *        mouse event
     * @param menu
     *        a menu to show
     * @param parent
     *        a component for menu
     */
    public static void maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent) {
        if (e.isPopupTrigger()) {
            menu.show(parent, e.getX(), e.getY());
        }
    }
}

Related

  1. getPopupMenuShowPoint(JPopupMenu popup, int x, int y)
  2. insertSeparatorIfNeeded(JPopupMenu popupMenu, int position)
  3. installPopupMenuColorAndFonts(final JComponent contentPane)
  4. isPopupMenuSeparator(Component component)
  5. makePopupMenu(JPopupMenu menu, List menuItems)
  6. optimizeSeparators(JPopupMenu menu)
  7. positionPopup(Component component, JPopupMenu jpm, int xCoord, int yCoord)
  8. positionPopupMenu(final JPopupMenu popupMenu, final MouseEvent event, final Rectangle rectangle, final int dividerlocation)
  9. refreshPopup(JPopupMenu popup)