• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

javafx control textfield

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friends!

for to do control to TextField in javafx i write this code:



with this code don't to do the control!

why??

help!
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to a more appropriate forum than Swing
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The conditions in your if statement are problematic:

testo.equals("") - testo is an instance of of the JavaFX TextField. It cannot equal to any String. You need to obtain the actual value of the control by calling the getText() method.

testo.getText()=="" - here you've avoided the previous mistake, but now you're comparing Strings using the equality operator. That's not going to work in Java, you need to use equals(). See AvoidTheEqualityOperator.

testo.getText()== null - I don't think TextField.getText() can ever return null, but even if it could, it would be better to test this case first. Testing it last doesn't make sense, you'd get a NullPointerException on the previous tests (well, assuming they would be implemented correctly).

Disclaimer: I don't know JavaFX, so there might be other problems here.
 
permaculture is largely about replacing oil with people. And one tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic