I currently have an actionListener set up to detect whether or not the checkBox I have created is checked, and depending on this; set the value of taskType to either 'oneOff' (unchecked) or 'Routine (checked). The problem is that when the user submits the form by clicking the button, the received value is 'null' if the box is left unchecked, the only way to make the received value 'oneOff' is by checking the box and unchecking it again. How can I make the default unchecked value of the checkbox 'oneOff' - and is this even possible?
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
if(freqComboBox.getSelectedIndex() == -1 && checkBox.isSelected())
{
freqLabel.setEnabled(true);
freqComboBox.setEnabled(true);
createTask.setEnabled(false);
}
else if(checkBox.isSelected())
{
freqLabel.setEnabled(true);
freqComboBox.setEnabled(true);
taskType = "Routine";
}
else
{
freqLabel.setEnabled(false);
freqComboBox.setEnabled(false);
freqComboBox.setSelectedIndex(-1);
taskType = "oneOff";
}
}
});