• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Checking TextField input constraints

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(A bit long-winded, but a simple question...)

I've created TextField using:

tf2 = new TextField("Enter whatever:", null, 15, TextField.PASSWORD | TextField.NON_PREDICTIVE);

Later on in my code, I want to check whether tf2 has the PASSWORD contraint.

Because I also included the NON_PREDICTIVE constraint, the following detection code doesn't work:

if (tf2.getConstraints() == TextField.PASSWORD) {
//code a
}
else {
//code b
}

So what's the correct way to detect?

Thanks,
James
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if ((getConstraints() & PASSWORD) == PASSWORD) {
//code a
}
else {
//code b
}
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic