Here you can find the source of positionPopupMenu(final JPopupMenu popupMenu, final MouseEvent event, final Rectangle rectangle, final int dividerlocation)
Parameter | Description |
---|---|
popupMenu | a parameter |
event | a parameter |
rectangle | a parameter |
dividerlocation | a parameter |
public static void positionPopupMenu(final JPopupMenu popupMenu, final MouseEvent event, final Rectangle rectangle, final int dividerlocation)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; public class Main { /*********************************************************************************************** * Position a Popup Menu relative to the selected node, * but always so that the left edge is not beyond the tree panel given by dividerlocation. */* w ww . ja v a 2s .c o m*/ * @param popupMenu * @param event * @param rectangle * @param dividerlocation */ public static void positionPopupMenu(final JPopupMenu popupMenu, final MouseEvent event, final Rectangle rectangle, final int dividerlocation) { int intPopupLeft; intPopupLeft = (int) rectangle.getX() + (int) rectangle.getWidth(); if (intPopupLeft > dividerlocation) { intPopupLeft = dividerlocation - 50; } popupMenu.show(event.getComponent(), intPopupLeft, (int) rectangle.getY() + ((int) rectangle.getHeight() >> 1)); } }