i'm trying to modify a java code. I have a jSpinner where the user have to choose a number like minimum 0 and after this step the user can continue by clicking the OK button and continue his steps...
So here what i want is when the user didn't enter any value in the jSpinner and if he clicks the OK button to continue, it must display "Error you must enter minimum value 1!" and stop to go to the next step. The user must stay in the same window.
For this what i tried is to create a piece of code like this:
public int getAlerte() {
int x = 0;
if (Integer.parseInt(jSpinnerParameter.getValue().toString()) <= -1 ||
Integer.parseInt(jSpinnerParameter.getValue().toString()) >200) {
JOptionPane.showMessageDialog(this, " ID number must be minimum 1",
"Alert", JOptionPane.ERROR_MESSAGE);
x = 1;
}
return x;
}
I put this line in the starting of the code: import javax.swing.JOptionPane;
After this, when i enter -1 or nothing (initial value=0) it never display the error message.
Why the message is not displayed, could someone help please? i can't see the bug.
Thank you