I'm writing my first Java Swing Applet, and wanted to include a JFormattedTextField that only allowed integers greater than 0. The bit of my code is this;
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFormattedTextField txt = new JFormattedTextField(Object 1);
add(txt); //creating the JFormattedTextField
}
});
} catch (Exception e) {
System.err.println("Please enter new number."); //Catching any numbers less than one.
}