Java JPopupMenu cleanPopupLayoutMetrics(JPopupMenu popupMenu)

Here you can find the source of cleanPopupLayoutMetrics(JPopupMenu popupMenu)

Description

Cleans the layout metrics of the specified popup menu.

License

Open Source License

Parameter

Parameter Description
popupMenu Popup menu.

Declaration

public static void cleanPopupLayoutMetrics(JPopupMenu popupMenu) 

Method Source Code

//package com.java2s;
import java.awt.Component;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

public class Main {
    /**//ww  w .  java2 s. co  m
     * Key to store the layout metrics. The value should be an instance of
     * {@link MenuLayoutMetrics}.
     */
    private static final String LAYOUT_METRICS = "substancelaf.internal.menus.layoutMetrics";

    /**
     * Cleans the layout metrics of the popup menu of the specified menu item.
     * 
     * @param menuItem
     *            Menu item.
     */
    private static void cleanPopupLayoutMetrics(JMenuItem menuItem) {
        Component comp = menuItem.getParent();
        if (comp instanceof JPopupMenu) {
            JPopupMenu popupMenu = (JPopupMenu) comp;
            cleanPopupLayoutMetrics(popupMenu);
        }
    }

    /**
     * Cleans the layout metrics of the specified popup menu.
     * 
     * @param popupMenu
     *            Popup menu.
     */
    public static void cleanPopupLayoutMetrics(JPopupMenu popupMenu) {
        if (popupMenu != null) {
            popupMenu.putClientProperty(LAYOUT_METRICS, null);
        }
    }
}

Related

  1. addSeparatorIfNecessary(JPopupMenu popup)
  2. addSeparatorIfNecessary(JPopupMenu popup)
  3. addSeparatorIfNeeded(JPopupMenu popupMenu)
  4. applyDefaultProperties(final JPopupMenu comp)
  5. attachPopupMenu(final JComponent component, final JPopupMenu popupMenu)
  6. computePopupLocation(MouseEvent event, Component rel, JPopupMenu popup)
  7. createPopupMenu()
  8. createPopupMenu(String menuText, JPopupMenu menu, ActionListener listener)
  9. ensurePopupIsOnScreen(JPopupMenu popup)