Here you can find the source of maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent)
Parameter | Description |
---|---|
e | mouse event |
menu | a menu to show |
parent | a component for menu |
public static void maybeShowPopup(MouseEvent e, JPopupMenu menu, JComponent parent)
//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()); } } }