/*
 * PopupListener.java
 * 
 * Copyright (c) 2001-2002 Digi International
 * This program and the information contained in it is confidential and
 * proprietary to Digi International and may not be used, copied, or re-
 * produced without the prior written permission of Digi International.
 * 
 */

package com.digi.config.ui;


import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JPopupMenu;


/**
 * Listener for mouse events related to popup menus.
 */
class PopupListener extends MouseAdapter {
    private JPopupMenu popup;
    private Component component;

    public PopupListener(JPopupMenu popup, Component component) {
        this.popup=popup;
        this.component=component;
        popup.setInvoker(component);
    }

    public void mousePressed(MouseEvent e) {
        if (e.isPopupTrigger()) {
            popup.show(component, e.getX(), e.getY());
            //            popup.setLocation(e.getPoint());
            //            popup.setVisible(true);
        }
    }

    public void mouseClicked(MouseEvent e) {
        if (e.isPopupTrigger()) {
            popup.show(component, e.getX(), e.getY());
            //            popup.setLocation(e.getPoint());
            //            popup.setVisible(true);
        }
    }

    public void mouseReleased(MouseEvent e) {
        if (e.isPopupTrigger()) {
            popup.show(component, e.getX(), e.getY());
            //            popup.setLocation(e.getPoint());
            //            popup.setVisible(true);
        }
    }

}

