Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 11:04 PM
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:17 AM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
Null is not the same as empty-- null means undefined, empty means defined and, well, empty

So try if (animationDelay == "") instead, see if that works for you.

Greetings.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NULL Value Of parameters riders JavaServer Pages (JSP) and JSTL 0 03-14-2008 03:29 PM
Comparing null problem thirdy_veritech New To Java 2 02-06-2008 09:46 AM
What is NULL bugger New To Java 1 01-09-2008 05:55 PM
parameters=null mary Java Servlet 1 07-13-2007 05:29 PM
JTextFields with username & password. Eric AWT / Swing 2 07-02-2007 12:41 AM


All times are GMT +3. The time now is 08:29 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org