Forum
For more in-depth forums, please visit the forums on WorldDeveloper.org, http://worlddeveloper.org/www/forums.html. You must login to post a message.


masood
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class TextFieldExample extends MIDlet implements CommandListener{
private Form form,f,m;
private Display display;
private TextField t;
private Command ok,exit,back,screen;
public TextFieldExample(){
display = Display.getDisplay(this);
t = new TextField("Name:", "", 30, TextField.ANY);

ok = new Command("OK", Command.OK, 0);
exit = new Command("EXIT", Command.EXIT, 1);
back = new Command("BACK", Command.BACK,2);
screen = new Command("SCREEN", Command.SCREEN,3);
}

public void startApp(){

Form form = new Form("Text Field");
form.addCommand(back);
form.addCommand(exit);
form.setCommandListener(this);
display.setCurrent(form);
}

public void pauseApp(){

}

public void destroyApp(boolean destroy){
notifyDestroyed();
}
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
if(label.equals("OK")){
showInput();
} else if(label.equals("EXIT")){
notifyDestroyed();
} else if(c ==back) {
showBack() ; }
else if(c ==screen) {
showBack() ; }
}
public void showInput(){
display = Display.getDisplay(this);
String s = t.getString();
String string = helpDATA();
Form f = new Form("fr");
f.append(s);
f.append(string);
f.addCommand(screen);
f.setCommandListener(this);
display.setCurrent(f);
}
public void showBack() {
display = Display.getDisplay(this);
Form m = new Form("MT");
m.append(t);
m.append("TEXT");
m.addCommand(ok);
m.setCommandListener(this);
display.setCurrent(m);
}

private String helpDATA(){
InputStream is = getClass().getResourceAsStream(t.getString()+".txt");
StringBuffer sb = new StringBuffer();
try{
int chars, i = 0;
while ((chars = is.read()) != -1){
sb.append((char) chars);
}
return sb.toString();
}catch (Exception e){
System.out.println("Can't create Buffers");
}
return null; }

}
I fitted and wrote these codes , this application must
read file from RES after inserting file's name in TextField and after pressing OK , this app. does this work and show its contents but after pressing SCREEN it dont return to first page.
Please direct me and if might , complete these codes .
Thanks.
26/03/09 12:57 PM
Advertising  /  Build  /  Terms  /  Comments  /  Libraries  /  Devices  /  Clients  /  Forum  /  blog  /  xhtml
Consulting - Buy, Run, Invest - ©2011 Astrient Labs, LLC 
Buy, Run, Invest Consulting