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....

Reply With Quote



