• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

textfield = null?

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
scheide
Asked:
scheide
1 Solution
 
mann061997Commented:
Use this statement:

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

or

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

0
 
scheideAuthor Commented:
Clear and concise answer...I assume it works and will test it.
Thanks...and boy do I feel silly/stupid. :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now