processing id create
/**
* No Repeat ID Input (v1.10)
* by GoToLoop (2013/Nov)
*
* forum.processing.org/two/discussion/869
* /check-array-contents-with-arraylist
*/
import static javax.swing.JOptionPane.*;
final StringList ids = new StringList( new String[] {
"Eric", "Beth", "Katniss"
}
);
void draw() {
println(ids);
final String id = showInputDialog("Please enter new ID");
if (id == null) exit();
else if ("".equals(id))
showMessageDialog(null, "Empty ID Input!!!",
"Alert", ERROR_MESSAGE);
else if (ids.hasValue(id))
showMessageDialog(null, "ID \"" + id + "\" exists already!!!",
"Alert", ERROR_MESSAGE);
else {
showMessageDialog(null, "ID \"" + id + "\" successfully added!!!",
"Info", INFORMATION_MESSAGE);
ids.append(id);
}
}