Example usage for javax.swing JPopupMenu addFocusListener

List of usage examples for javax.swing JPopupMenu addFocusListener

Introduction

In this page you can find the example usage for javax.swing JPopupMenu addFocusListener.

Prototype

public synchronized void addFocusListener(FocusListener l) 

Source Link

Document

Adds the specified focus listener to receive focus events from this component when this component gains input focus.

Usage

From source file:com.anrisoftware.prefdialog.miscswing.components.menu.PopupMenuComponent.java

/**
 * Sets the pop-up menu.//from w w w . j a  va  2 s  . c  om
 * 
 * @param menu
 *            the {@link JPopupMenu}.
 * 
 * @throws NullPointerException
 *             if the specified menu is {@code null}.
 */
public void setPopupMenu(JPopupMenu menu) {
    notNull(component);
    JPopupMenu oldValue = this.menu;
    this.menu = menu;
    if (oldValue != null) {
        oldValue.removeFocusListener(menuFocusListener);
    }
    menu.addFocusListener(menuFocusListener);
}