Java JPopupMenu showPopupMenu(JPopupMenu popup, Component invoker, int x, int y)

Here you can find the source of showPopupMenu(JPopupMenu popup, Component invoker, int x, int y)

Description

Shows the popup menu with the consideration of the invoker's orientation.

License

Open Source License

Parameter

Parameter Description
popup the popup menu
invoker the invoker for the popup menu
x the x, usually the x of the mouse clicked position
y the y, usually the y of the mouse clicked position

Declaration

public static void showPopupMenu(JPopupMenu popup, Component invoker,
        int x, int y) 

Method Source Code

//package com.java2s;
import javax.swing.*;

import java.awt.*;

public class Main {
    /**//from  ww w.j ava 2  s.  c  o m
     * Shows the popup menu with the consideration of the invoker's orientation.
     *
     * @param popup   the popup menu
     * @param invoker the invoker for the popup menu
     * @param x       the x, usually the x of the mouse clicked position
     * @param y       the y, usually the y of the mouse clicked position
     */
    public static void showPopupMenu(JPopupMenu popup, Component invoker,
            int x, int y) {
        popup.applyComponentOrientation(invoker.getComponentOrientation());
        if (popup.getComponentOrientation().isLeftToRight()) {
            popup.show(invoker, x, y);
        } else {
            popup.show(invoker, x - popup.getPreferredSize().width, y);
        }

    }
}

Related

  1. showPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)
  2. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  3. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  4. showPopupMenu(JPopupMenu popup, Component comp, int x, int y)
  5. showPopupMenu(JPopupMenu popup, Component comp, int x, int y, boolean point)
  6. showPopupPanel(Component activationComponent, JPopupMenu popup)
  7. updateOrInsertMenuItem(JPopupMenu menu, JMenuItem menuItem)
  8. willPopupBeContained(JPopupMenu popup, Point origin)