static void setMenuItemWithoutNotifyingListeners(final JMenuItem mi, final boolean selected) {
		if (mi == null)
			return;
		ItemListener[] il = mi.getItemListeners();
		if (il != null) {
			for (ItemListener x : il)
				mi.removeItemListener(x);
		}
		ActionListener[] al = mi.getActionListeners();
		if (al != null) {
			for (ActionListener x : al)
				mi.removeActionListener(x);
		}
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				mi.setSelected(selected);
			}
		});
		if (il != null) {
			for (ItemListener x : il)
				mi.addItemListener(x);
		}
		if (al != null) {
			for (ActionListener x : al)
				mi.addActionListener(x);
		}
	}