Java Utililty Methods JPopupMenu

List of utility methods to do JPopupMenu

Description

The list of methods to do JPopupMenu are organized into topic(s).

Method

voidshowPopMenuWithParentWidth(JPopupMenu popup, Component parentComponent, int x, int y)
show Pop Menu With Parent Width
if (popup == null) {
    return;
Dimension size = popup.getPreferredSize();
size.width = Math.max(size.width, parentComponent.getWidth());
popup.setPreferredSize(size);
showPopupCloseMenu(popup, parentComponent);
voidshowPopup(JPopupMenu popup, MouseEvent event)
Ensures that the popup menue is allways inside the application frame
if (popup == null) {
    return;
final Component component = event.getComponent();
final Point point = event.getPoint();
popup.show(component, point.x, point.y);
voidshowPopupCloseMenu(JPopupMenu popup, Component parentComponent)
show Popup Close Menu
if (popup == null) {
    return;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Window frame = SwingUtilities.getWindowAncestor(parentComponent);
int leftX = 0;
int rightX = parentComponent.getLocation().x + frame.getLocation().x + popup.getPreferredSize().width;
if (rightX > screenSize.width) {
...
voidshowPopupMenu(final JPopupMenu popup, final Component component, int x, int y)
show Popup Menu
final Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, component);
final Dimension size = popup.getPreferredSize();
final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
boolean horiz = false;
boolean vert = false;
final int origX = x;
if ((p.x + size.width > screen.width) && (size.width < screen.width)) {
...
voidshowPopupMenu(javax.swing.JPopupMenu popup, Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
Point p = getBestAnchorPoint(comp, x, y);
popup.show(comp, p.x, p.y);
voidshowPopupMenu(javax.swing.JPopupMenu popup, Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
Point p = getBestAnchorPoint(comp, x, y);
popup.show(comp, p.x, p.y);
popup.show(comp, x, y);
voidshowPopupMenu(JPopupMenu menu, Component invoker, MouseEvent e)
Displays a popup menu.
showPopupMenu(menu, invoker, e.getXOnScreen(), e.getYOnScreen());
voidshowPopupMenu(JPopupMenu popup, Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
showPopupMenu(popup, comp, x, y, true);
voidshowPopupMenu(JPopupMenu popup, Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
Point p = new Point(x, y);
SwingUtilities.convertPointToScreen(p, comp);
Dimension size = popup.getPreferredSize();
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
boolean horiz = false;
boolean vert = false;
int origX = x;
if (p.x + size.width > screen.width && size.width < screen.width) {
...
voidshowPopupMenu(JPopupMenu popup, Component comp, int x, int y)
Shows the specified popup menu, ensuring it is displayed within the bounds of the screen.
showPopupMenu(popup, comp, x, y, true);