BitSet (boolean applyDefaults) { BitSet state = new BitSet(3); state.set(0, !applyDefaults && searchInCommentsCheckBox.isSelected()); //searchInCommentsCheckBox default is false state.set(1, !applyDefaults && searchForTextOccurrencesCheckBox.isSelected()); //searchForTextOccurrencesCheckBox default is false state.set(2, passOuterClassCheckBox.isSelected()); return state; }