Is this what you wanted:
int n;
String code = JOptionPane.showInputDialog(null,
"Enter the size of the group",
"Team Combination Finder",
JOptionPane.INFORMATION_MESSAGE);
if (code == null) {
System.out.println("This is cancel button");
System.exit(0);
} else if (code.equalsIgnoreCase("")) {
System.out.println("This is OK button without input");
} else {
try {
n = Integer.parseInt(code);
if (n <= 0) {
System.out.println("This is wrong input");
} else {
System.out.println("This is right input");
}
} catch (Exception e) {
System.out.println("You must input numeric only");
}
}
See if it works for you :)