I have a ComboBox defined as follows:

private String[] months = {"Month", "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12"};
private JComboBox jComboBoxMonth = null;

and down further I have:

jComboBoxMonth = new JComboBox(months);

Now i am trying to do run an if statement which checks to see if the word "Month" is what is appearing in the ComboBox. So down further I have:

if (jComboBoxMonth.equals("Month") {
and my code is here.

Is the above test in the if statement being carried out, as i suspect that it isn't.

Anyone any ideas.

Thanks
Paidi

No, you have to first call currently selected item String selectedOption = (String) jComboBoxMonth.getSelectedItem() and then you can compare it as you did it if (selectedOption.equals("Month")

This article has been dead for over six months. Start a new discussion instead.