Help with dropdown list
Hi, My requirement is that i have a radio button fail.after selecting data I have to select the reason also using the dropdown list. If the reason is not selected an error should be thrown. How to accomplish this in java.can anyone please help.
There are many ways you could do this, some more difficult than others. I will list a couple of ideas, but depending on how your code has been written, they might not fit in.
1) You could set the first value in the combo box to be "none", then you could obtain the value from the combo box and check that the value is not equal to "none" i.e. if(!ComboValue.compareTo("none")) //something like that.
2)The other way you could do this, would be to have a boolean global variable called "reason"(this is a bad name) set to false. When the check box is then used, inside the combobox handler set "reason" to true, then you can check the status of "reason". But remember to set it back to false again.
System.out.println.........please select reason....(whatever)
With both of these examples i am assuming you have a JButton that you press after the fail radio button is pressed to submit the reason. These are both very simple examples. But they will both work.