void (ActionEvent e) { JCheckBox toCheck = null; if (!myWatchEntryCheckBox.isSelected() && !myWatchExitCheckBox.isSelected()) { Object source = e.getSource(); if (myWatchEntryCheckBox.equals(source)) { toCheck = myWatchExitCheckBox; } else if (myWatchExitCheckBox.equals(source)) { toCheck = myWatchEntryCheckBox; } if (toCheck != null) { toCheck.setSelected(true); } } }