Mi Codigo
import java.io .*;
import javax.microedition.lcdui .*;
javax.microedition.io import .*;
javax.microedition.midlet import .*;
public class Main extends MIDlet implements CommandListener {private Display display
= null;
private String url = "http://ivanchi.site88.net/docs/infopersonal;
private String url2 = "http://ivanchi.site88.net/docs/infoadicional";
List menu = null;
TextBox input = null;
TextBox t=null;
static final Command backCommand = new Command("Back", Command.BACK, 0);
static final Command mainMenuCommand = new Command("Main", Command.SCREEN,1);
static final Command exitCommand = new Command("Exit", Command.STOP, 2);
String currentMenu = null;
public Principal() {
display =Display.getDisplay(this);
}
public void startApp() throws MIDletStateChangeException {
display = Display.getDisplay(this);
menu = new List ("Menu Items", Choice.IMPLICIT)
menu.append ("General Information", null);
menu.append ("Additional Information", null);
menu.addCommand (exitCommand) ;
menu.setCommandListener (this);
MainMenu ();
} public void download (String url) throws IOException {
StringBuffer b = new StringBuffer ();
InputStream is = null;
try {long len = 0; int ch = 0;
c = (HttpConnection) Connector.open (url);
is = c.openInputStream();
while ((ch=is.read()) !=-1){
b.append((char)ch);
}
t = new TextBox("Hola..." ,b.toString(), 1024,0);
t.addCommand(backCommand);
t.setCommandListener(this);
mainMenu();
} finally {
if(is !=null)
is.close();
if(c !=null)
c.close();
}
display.setCurrent(t);
}
public void pauseApp() {
display = null;
menu = null;
input = null;
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
void mainMenu() {
display.setCurrent(menu); currentMenu = "Main";
}
public void testIteml() {
display = Display.getDisplay(this);
try{
download(url);
} catch(IOException e){
System.out.println("IOException" + e);
}
}
public void testItem2() {
display = Display.getDisplay(this);
try {
download (url2);
} catch (IOException e) {
System.out.println ("IOException" + e);
}} public void
commandAction (Command c, Display d) {String label
= c.getLabel ();
if (label.equals ("Exit")) {
destroyApp (true);
} else if (label.equals ("Back")) {
if (currentMenu.equals ("Data General ")
}} else {
List down = (List) display.getCurrent ();
switch (down.getSelectedIndex ()) {case 0
: testIteml () break;
case 1: testItem2 () break;}
}}}
0 comments:
Post a Comment