I am experimenting with variations on the dialog box tutorial on Oracle. I felt that the number of options I offered resulted in too many buttons so I converted from OptionDialog to InputDialog and used an Object array. Now, however, my switch statement (in replyMessage) doesn't work because of the change in data type. How do I get the index in the Object array corresponding to the user's selection?
Object answer;
int ansInt;//the user'a answer stored as an int
Object[] options = {"Yes, please",
"No, thanks",
"No eggs, no ham!",
"Something else",
"Nothing really"
};//end options
answer = JOptionPane.showInputDialog(null, "Would you like some green eggs to go with that ham?",
"A Silly Question",
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[2]);
ansInt = ;//supposed to be the index of user's seleection
replyMessage(ansInt);