Example usage for javax.swing JComponent addMouseListener

List of usage examples for javax.swing JComponent addMouseListener

Introduction

In this page you can find the example usage for javax.swing JComponent addMouseListener.

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:tvbrowser.ui.mainframe.MainFrame.java

private void addContextMenuMouseListener(final JComponent c) {
    c.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                ContextMenu menu = new ContextMenu(c);
                menu.show(e.getX(), e.getY());
            }//from   w w  w  .j  a  va2 s  .  c  o m
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                ContextMenu menu = new ContextMenu(c);
                menu.show(e.getX(), e.getY());
            }
        }
    });
}