Using JOptionPane.showInputDialog to return an integer
I am currently using JOptionPane to return a string from the Object array i made with all possible choices.
privatestaticboolean determineService(){
JLabel label;
label=new JLabel("Please select which Service Model to use.",JLabel.CENTER);
Object[] possibilities ={"AddressCleanse","VIN","PostalCode"};
serviceModel = (String)JOptionPane.showInputDialog(
null,
label,
"Select Service",
JOptionPane.PLAIN_MESSAGE,null,
possibilities,
"AddressCleanse");
//If a string was returned, say so.
if ((serviceModel !=null) && (serviceModel.length() > 0)){
System.out.println("You've selected " + serviceModel +"!");
setVariables();
returntrue;
}else{
//If you're here, the return value was null/empty.
System.out.println("Null or Bad service selected!\n Exiting program.");
returnfalse;
}
I would like to instead return the response as an integr so I can then use a switch, rather than recursive if, else if logic.
Apparently java doesnt allow switches to use strings (like PHP does)
any ideas?

