I have the following code:
// Select race and make sure it's not empty
do {
race = JOptionPane.showInputDialog(null, "Choose Race:", "Input", JOptionPane.INFORMATION_MESSAGE, null, racesNames, racesNames[0]);
if (!(race == null)) {
int raceIndex = ArrayUtils.indexOf(racesNames, race);
race = racesArray[raceIndex]; // Convert from name to full character JSONObject
}
}
while (race == null);
It's supposed to let the user select from a list of race names, and after being selected, it changes that race name object to be the full JSONObject of the race from another list with the same indexes.
If a race isn't selected, the dialog is reopened until a valid option is selected. However, I'm not sure how to manipulate the JSONObject past the do-while because Java doesn't know that it's going to be a JSONObject no matter what.
Is there any way around this? Thanks in advance!