Example usage for javax.swing JComponent getComponentPopupMenu

List of usage examples for javax.swing JComponent getComponentPopupMenu

Introduction

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

Prototype

@SuppressWarnings("deprecation")
public JPopupMenu getComponentPopupMenu() 

Source Link

Document

Returns JPopupMenu that assigned for this component.

Usage

From source file:Main.java

/**
 * Repaints UI tree recursively.//from ww  w. j  av  a  2  s  . c om
 *
 * @param c UI component.
 */
private static void updateComponentTreeUI0(Component c) {
    if (c instanceof JComponent) {
        JComponent jc = (JComponent) c;
        jc.invalidate();
        jc.validate();
        jc.repaint();
        JPopupMenu jpm = jc.getComponentPopupMenu();
        if (jpm != null && jpm.isVisible() && jpm.getInvoker() == jc) {
            updateComponentTreeUI(jpm);
        }
    }
    Component[] children = null;
    if (c instanceof JMenu) {
        children = ((JMenu) c).getMenuComponents();
    } else if (c instanceof java.awt.Container) {
        children = ((java.awt.Container) c).getComponents();
    }
    if (children != null) {
        for (int i = 0; i < children.length; i++)
            updateComponentTreeUI0(children[i]);
    }
}