If you are experiencing an issue please mention the full platform your 
issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator 
Device

NetBeans platform

Hi guys, so I have a problem in my code, so I'm starting some kind of login 
form and I wan't to check if the textfield is empty or not before adding 
the values to the variables but when I added the new if :

if (username.getText()==null || username.getText().trim().isEmpty())

I got this build output:

ant -f "G:\\Codename One\\CodenameOne" -Dnb.internal.action.name=rebuild 
clean jar
No GUI Entries available
init:
deps-clean:
Updating property file: G:\Codename 
One\CodenameOne\build\built-clean.properties
Deleting directory G:\Codename One\CodenameOne\build
refresh-libs:
Deleting directory G:\Codename One\CodenameOne\lib\impl
clean:
No GUI Entries available
init:
deps-jar:
Created dir: G:\Codename One\CodenameOne\build
Updating property file: G:\Codename 
One\CodenameOne\build\built-jar.properties
Created dir: G:\Codename One\CodenameOne\build\classes
Compile is forcing compliance to the supported API's/features for maximum 
device compatibility. This allows smaller
        code size and wider device support
Created dir: G:\Codename One\CodenameOne\build\tmp
Compiling 1 source file to G:\Codename One\CodenameOne\build\tmp
G:\Codename One\CodenameOne\src\com\mycompany\myapp\mainclassZ.java:103: 
error: cannot find symbol
                if (username.getText()==null || 
username.getText().trim().isEmpty()){
  symbol:   method isEmpty()
  location: class String
1 error
G:\Codename One\CodenameOne\build.xml:57: Compile failed; see the compiler 
error output for details.
BUILD FAILED (total time: 2 seconds)

So this is the code of my login form:

Form login = new Form("Login");
        setBackCommand(login);
        TextField username = new TextField("","Username", 20, 
TextField.INITIAL_CAPS_WORD);
        TextField password = new TextField("", "Password", 20, 
TextField.PASSWORD);
        Button userlogin = new Button("Login");
        
        userlogin.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent evt){
                if (logged==false){                    
                if (username.getText()==null || 
username.getText().trim().isEmpty()){
                    Dialog.show("Warning!", "Please, fill all the fields!", 
"Ok","Cancel");
                }                    
                else{
                    //How do I add the textfield content to the variables 
user1 and pass1?
                    Dialog.show("Logged in!", "Log in successful! Welcome 
"+user1+"!", "Ok", "Close Dialog");
                    logged=true;
                    user1=username.getText();
                    pass1=password.getText();
                }                
                }
                else
                    Dialog.show("Warning!", "You are already logged into an 
account please log out first!","Ok", "Cancel");
            }            
        }); 

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/94bb2e3f-68d2-4a33-ae70-b904923633fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to