Ejemplo n.º 1
0
  /**
   * Returns a <code>Popup</code> instance from the <code>PopupMenuUI</code> that has had <code>show
   * </code> invoked on it. If the current <code>popup</code> is non-null, this will invoke <code>
   * dispose</code> of it, and then <code>show</code> the new one.
   *
   * <p>This does NOT fire any events, it is up the caller to dispatch the necessary events.
   */
  private Popup getPopup() {
    Popup oldPopup = popup;

    if (oldPopup != null) {
      oldPopup.hide();
    }
    PopupFactory popupFactory = PopupFactory.getSharedInstance();

    if (isLightWeightPopupEnabled()) {
      popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    } else {
      popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
    }

    // adjust the location of the popup
    Point p = adjustPopupLocationToFitScreen(desiredLocationX, desiredLocationY);
    desiredLocationX = p.x;
    desiredLocationY = p.y;

    Popup newPopup = getUI().getPopup(this, desiredLocationX, desiredLocationY);

    popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
    newPopup.show();
    return newPopup;
  }
Ejemplo n.º 2
0
 public void mouseReleased(MouseEvent e) {
   if (e.isPopupTrigger()) {
     Popup popup = new Popup();
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }