boolean (JMenuItem item) { if (item == null) return false; ButtonModel model = item.getModel(); if (model == null) return false; return model.isArmed() || (item instanceof JMenu) && model.isSelected(); }