You are on page 1of 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package hora;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.*;

/**
* @author pc04-lab01
*/
public class InfoDispositivo extends MIDlet implements CommandListener {
private Command salir;
private Display display;
private Form pantalla;

public InfoDispositivo(){
//recuperar el objetivo DISPLAY

display=Display.getDisplay(this);
//creamos el comando salida
salir=new Command("Salir",Command.EXIT,2);
//creamos el fORM de la pantalla principal
pantalla=new Form("InfoDispositivo");
//optenemos la hora
Calendar calendar=Calendar.getInstance();
String hora=Integer.toString(calendar.get
(Calendar.HOUR_OF_DAY))+":"+
Integer.toString(calendar.get(Calendar.MINUTE))+":"+
Integer.toString(calendar.get(Calendar.SECOND));
//MEMORIA TOTAL Y LA LIBRE
Runtime runtime=Runtime.getRuntime();
String memTotal=Long.toString(
runtime.totalMemory());
String memLibre=Long.toString(
runtime.freeMemory());
//obtenemos las propiedades de la pantalla
String color=display.isColor() ? "SI" : "NO";
String numColores=Integer.toString(
display.numColors());
//creamos las cadenas de informacion
//las añadimos a la pantalla

pantalla.append(new StringItem(
"","Hora:"+hora+"\n"));
pantalla.append(new StringItem(
"","Mem Total:"+memTotal+"b\n"));
pantalla.append(new StringItem(
"","Mem Libre:"+memLibre+"b\n"));
pantalla.append(new StringItem(
"","Color:"+color+"\n"));
pantalla.append(new StringItem(
"","Colores:"+numColores +"\n"));
//establecimiento el comando de salida
pantalla.addCommand(salir);
pantalla.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {

display.setCurrent(pantalla);
}

public void pauseApp() {


}

public void destroyApp(boolean incondicional, Command c) throws


MIDletStateChangeException{
if (c ==salir){
destroyApp(false);
notifyDestroyed();

}
}

protected void destroyApp(boolean unconditional) throws


MIDletStateChangeException {
throw new UnsupportedOperationException("Not supported yet.");
}

public void commandAction(Command c, Displayable d) {


throw new UnsupportedOperationException("Not supported yet.");
}

You might also like