View Single Post
  #1 (permalink)  
Old 07-17-2007, 12:04 AM
romina romina is offline
Member
 
Join Date: Jul 2007
Posts: 26
romina is on a distinguished road
Problem with JTextFields not null
I have a some JTextFields that I want to verify the contents of. IF the field is left blank it will add a message to my error window ELSE it will preform another check.

The OTHER check works fine, but it never seems to give me the proper error message if the field is blank, it immediatly goes to the ELSE statement.

If I do a
Code:
System.out.println(variableName);
, the variable appears to be NULL.

Code:
//animation delay is the name of the textfield animationDelay = this.animationDelay.getText(); /* check if animation delay was left blank */ if (animationDelay == null || animationDelay == ""){ errMsg.add("Please enter disk Animation Delay"); } else { /* check if the input given is valid */ try { /* parse the animation delay entered into an integer */ int animationDelayInt = Integer.parseInt(animationDelay); /* check range of animation delay */ if (animationDelayInt < MIN_ANIMATION_DELAY){ errMsg.add("Animation Delay must be greater than 0"); } else if (animationDelayInt > MAX_ANIMATION_DELAY){ errMsg.add("Animation Delay must be less than " + MAX_ANIMATION_DELAY); } } catch (NumberFormatException ex) { errMsg.add("Animation Delay must be a Number"); }
if I manually set animationDelay = null; the proper error message is displayed.

why is the blank field not being detected as null?
Is there an invisible character that blank JTextFields insert in order to ruin my life?

Thanks
Reply With Quote
Sponsored Links