×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    93

    Arrow "cannot find symbol symbol" error in my coding

    Hello all,
    This is my coding. I got error like,

    cannot find symbol
    symbol : method setCurrent(javax.microedition.lcdui.Alert)
    location: class javax.microedition.lcdui.Displayable
    d.setCurrent(a);


    My coding is below, Bold my error occured lines.

    public class Net extends MIDlet implements CommandListener {
    TextField Username=null;
    TextField Location=null;
    Form subform,mainform;
    TextBox t=null;
    StringBuffer s=new StringBuffer();
    private Display d;
    private Alert a;
    private Command backcommand;
    private Command okcommand;
    private Command exitcommand;
    public void startApp() {
    d=Display.getDisplay(this);
    mainform=new Form("Log In Page");
    mainform.append("Logging In....");
    backcommand=new Command("Back",Command.BACK,2);
    mainform.addCommand(backcommand);
    subform=new Form("Identification");
    Username=new TextField("Your Name","",15,TextField.ANY);
    Location=new TextField("Your Location","",15,TextField.ANY);
    subform.append(Username);
    subform.append(Location);
    okcommand=new Command("Ok",Command.OK,2);
    exitcommand=new Command("Exit",Command.EXIT,2);
    subform.addCommand(okcommand);
    subform.addCommand(exitcommand);
    subform.setCommandListener(this);
    d.setCurrent(subform);

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
    if((c==okcommand)&&(d==subform)){
    if(Username.getString().equals("")||Location.getString().equals("")){
    Alert a=new Alert("Error","Please Enter Username & Location",null,AlertType.ERROR);
    a.setTimeout(Alert.FOREVER);
    d.setCurrent(a);
    }
    else{
    login(Username.getString(),Location.getString());
    }
    }
    if((c==backcommand)&&(d==mainform)){
    d.setCurrent(subform);
    }


    if((c==exitcommand)&&(d==subform)){
    notifyDestroyed();
    }
    }

    private void login(String Username, String Location) {
    HttpConnection connection=null;
    DataInputStream in=null;
    String url="http://www.forum.nokia.com/";
    OutputStream out=null;
    try {
    connection = (HttpConnection) Connector.open(url);
    connection.setRequestMethod(HttpConnection.POST);
    connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT");
    connection.setRequestProperty("User Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
    connection.setRequestProperty("Content-Language","en-CA");
    connection.setRequestProperty("Content-Length", ""+(Username.length()+Location.length()));
    connection.setRequestProperty("User name",Username);
    connection.setRequestProperty("Location", Location);

    out=connection.openDataOutputStream();
    out.flush();
    in=connection.openDataInputStream();
    int ch=in.read();

    while(ch!=-1){
    s.append((char)ch);
    System.out.print(ch);
    }
    // t=new TextBox("Reply",s.toString(),1024,0);
    mainform.append(s.toString());
    if(in!= null){
    in.close();
    }

    if(out!=null){
    out.close();
    }
    if(connection!=null){
    connection.close();
    }
    } catch (IOException ex) {
    ex.printStackTrace();
    }
    d.setCurrent(mainform);

    }
    }


    what is the problem in my program...Help me....

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: "cannot find symbol symbol" error in my coding

    IF You will look at the code carefully then you will find the that Display object and the displayable object inside the commandAction are the same and hence d was take from the commandAction one and the error was thrown.

    Change the name of either and you will be done,

    PHP Code:
    private Display d;

        public 
    void commandAction(Command cDisplayable d) {
            if((
    c==okcommand)&&(d==subform)){
                if(
    Username.getString().equals("")||Location.getString().equals("")){
                    
    Alert a=new Alert("Error","Please Enter Username & Location",null,AlertType.ERROR);
                    
    a.setTimeout(Alert.FOREVER);
                   
    d.setCurrent(a);
                } else{
                    
    login(Username.getString(),Location.getString());
                }
            }
            if((
    c==backcommand)&&(d==mainform)){
                
    d.setCurrent(subform);
            }
            
            
            if((
    c==exitcommand)&&(d==subform)){
                
    notifyDestroyed();
            }
        } 
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor
    Join Date
    Nov 2010
    Posts
    93

    Re: "cannot find symbol symbol" error in my coding

    Thank u Raj sir, i cleared my error as guided by you and run program successfully. Thank You.

    With Regards,

    Ram

Similar Threads

  1. Replies: 3
    Last Post: 2010-09-30, 11:06
  2. Replies: 0
    Last Post: 2006-08-25, 07:24
  3. Replies: 0
    Last Post: 2006-08-25, 07:19
  4. Replies: 2
    Last Post: 2006-06-13, 06:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×