static void destroyPopupMenu(JPopupMenu pm) {
		if (pm == null)
			return;
		pm.setInvoker(null);
		Component c;
		AbstractButton b;
		for (int i = 0, n = pm.getComponentCount(); i < n; i++) {
			c = pm.getComponent(i);
			if (c instanceof AbstractButton) {
				b = (AbstractButton) c;
				b.setAction(null);
				ActionListener[] al = b.getActionListeners();
				if (al != null) {
					for (ActionListener l : al)
						b.removeActionListener(l);
				}
				ItemListener[] il = b.getItemListeners();
				if (il != null) {
					for (ItemListener l : il)
						b.removeItemListener(l);
				}
			}
		}
		PopupMenuListener[] pml = pm.getPopupMenuListeners();
		if (pml != null) {
			for (PopupMenuListener l : pml)
				pm.removePopupMenuListener(l);
		}
		pm.removeAll();
	}