int choice = JOptionPane.showConfirmDialog(null, msg, "Waiting for card", JOptionPane.OK_CANCEL_OPTION);
if (JOptionPane.OK_OPTION == choice) {
//nothing to do
}
if (JOptionPane.CANCEL_OPTION == choice) {
throw new StopRequestFromUserException("Operation cancelled by user.");
}
}
if (1 == candidates.size()) {
terminal = candidates.get(0);
break;
}
if (1 < candidates.size()) {
Object[] names = new Object[candidates.size()];
for (int i = 0; i < candidates.size(); i++) {
names[i] = candidates.get(i).getName();
}
String s = (String) JOptionPane.showInputDialog(
null,
"Please select a terminal",
"Terminal selection",
JOptionPane.PLAIN_MESSAGE,
null,
names,
names[0]);
if (s == null) {
throw new StopRequestFromUserException();
}
for (int i = 0; i < candidates.size(); i++) {
if (candidates.get(i).getName().equals(s)) {
terminal = candidates.get(i);
break;