Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

textfield = null?

Posted on 1997-06-30
2
683 Views
Last Modified: 2006-11-17
I'm a Java newbie and have tried the following code in both VisualAge and Visual Cafe:

if (TextField1.getText() = null) //also tried if == ""
   then do something...

Although there is no text in the textfield, the above code
acts as though it is false and won't 'do something...'
What is the proper syntax to find out if a textfield is blank?
0
Comment
Question by:scheide
2 Comments
 
LVL 1

Accepted Solution

by:
mann061997 earned 50 total points
ID: 1222531
Use this statement:

  if (TextField1.getText().length() == 0) {
      //then do something...
  }

or

  if (TextField1.getText().equals("")) {
      //then do something...
  }

0
 

Author Comment

by:scheide
ID: 1222532
Clear and concise answer...I assume it works and will test it.
Thanks...and boy do I feel silly/stupid. :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in @AspectJ Based AOP with Spring 2 18
ejb example issues 3 18
Facing this issue for maven proxy setting 2 19
Java class and jar 3 19
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question