package yi.gui.helper;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class JPopupMenuShower extends MouseAdapter {

  private JPopupMenu popup;

  public JPopupMenuShower(JPopupMenu popup) {
    this.popup = popup;
  }

  private void showIfPopupTrigger(MouseEvent mouseEvent) {
    if (popup.isPopupTrigger(mouseEvent)) { // Java 1.3
//     if (mouseEvent.isPopupTrigger()) { -- Swing 1.1/Java 1.2
      popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
    }
  }

  public void mousePressed(MouseEvent mouseEvent) {
    showIfPopupTrigger(mouseEvent);
  }
  public void mouseReleased(MouseEvent mouseEvent) {
    showIfPopupTrigger(mouseEvent);
  }
}

