rodrigo

rodrigo
rodrigo

viernes, 8 de abril de 2011

NOTA : LAS IMAGENES son asi por que no teia tiempo de pasarlas a mi cel
y solo capture pantalla

CODIGO DE CAMBIO VERSION 1

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

public class Moneda extends MIDlet implements CommandListener {
static final String BD = "datos";

String nc = "Dolares";
String tmoneda = "dolar";


TextBox t=null;
Cliente c = new Cliente();

private ChoiceGroup moneda;

public TextField txtPesos;
private Display pantalla;


private Form frmAgregar;
private Command cmdGuardar;
private Command cmdCancelar;
private TextField nombre;
private TextField descuento;

private Form frmEliminar;
private Command cmdEliminar;
private TextField nombre2;

private Form frmBuscar;
private Command cmdBuscar;
private TextField nombre3;

private Form frmResultados;
public int itemResultados;

private List elmenu;
private Command cmdSalir;
private Command cmdSeleccionar;

private Alert acercade;
private Command cmdRegresar;


public Moneda() {

pantalla = Display.getDisplay(this);

RecordStore rs = null;

try
{
RecordStore.deleteRecordStore(BD);
}
catch( Exception e ){}
try
{
rs = RecordStore.openRecordStore(BD, true);
rs.closeRecordStore();
}
catch( RecordStoreException e )
{
System.out.println( e );
}


String opciones[] = {"Añadir", "Eliminar", "Busqueda", "Acerca de...."};
Image figuras[] = new Image[4];
try
{
figuras[0] = Image.createImage("/nuevo.png");
figuras[1] = Image.createImage("/borrar.png");
figuras[2] = Image.createImage("/buscar.png");
figuras[3] = Image.createImage("/acercade.png");
}
catch (Exception e){}
cmdSeleccionar = new Command("Seleccionar",Command.ITEM,1);
cmdSalir = new Command("Salir", Command.EXIT,1);
elmenu = new List("Sistema Movil", Choice.IMPLICIT,opciones,figuras);
elmenu.setSelectCommand(cmdSeleccionar);
elmenu.addCommand(cmdSalir);
elmenu.setCommandListener(this);


cmdGuardar = new Command("Guardar",Command.OK,2);
cmdCancelar = new Command("Cancelar", Command.BACK,2);
frmAgregar = new Form("Añadir Cliente");
nombre = new TextField("Nombre:","",30,TextField.ANY);
descuento = new TextField("Cantidad:","",4,TextField.NUMERIC);
frmAgregar.append(nombre);
frmAgregar.append(descuento);
frmAgregar.addCommand(cmdGuardar);
frmAgregar.addCommand(cmdCancelar);
frmAgregar.setCommandListener(this);

moneda = new ChoiceGroup("Tipo Moneda", Choice.EXCLUSIVE);
moneda.append("Dolares", null);
moneda.append("Euros", null);
moneda.append("Yenes", null);

frmAgregar.append(moneda);

cmdEliminar = new Command("Eliminar", Command.OK,2);
frmEliminar = new Form("Eliminar Cliente");
nombre2 = new TextField("Nombre:","",20,TextField.ANY);
frmEliminar.append(nombre2);
frmEliminar.addCommand(cmdEliminar);
frmEliminar.addCommand(cmdCancelar);
frmEliminar.setCommandListener(this);


cmdBuscar = new Command("Buscar", Command.OK,2);
frmBuscar = new Form ("Buscar Cliente");
nombre3 = new TextField("Nombre:","",20,TextField.ANY);
frmBuscar.append(nombre3);
frmBuscar.addCommand(cmdBuscar);
frmBuscar.addCommand(cmdCancelar);
frmBuscar.setCommandListener(this);


cmdRegresar = new Command("OK",Command.BACK,1);
frmResultados = new Form("Resultados");
itemResultados = frmResultados.append("Resultados");
frmResultados.addCommand(cmdRegresar);
frmResultados.setCommandListener(this);


acercade = new Alert(" Rodrigo = RodrizZ ");
acercade.setTimeout(Alert.FOREVER);
String creditos = "Creado por: \n RodrizZ";

if (pantalla.numColors() > 2)
{
String icon =(pantalla.isColor()) ?"/javaPowerd-8.png": "/javaPowerd-2png";
try
{
Image image = Image.createImage(icon);
acercade.setImage(image);
}
catch (java.io.IOException x){}
}
acercade.setString(creditos);
acercade.addCommand(cmdRegresar);
acercade.setCommandListener(this);

}



public void startApp() throws MIDletStateChangeException {
pantalla.setCurrent(elmenu);
}
public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s){

switch(c.getCommandType())
{
case Command.ITEM:
switch(elmenu.getSelectedIndex())
{
case 0://añadir
pantalla.setCurrent(frmAgregar);
break;
case 1://Eliminar
pantalla.setCurrent(frmEliminar);
break;
case 2://Buscar
pantalla.setCurrent(frmBuscar);
break;
case 3://Acerca De...
pantalla.setCurrent(acercade);

pantalla = Display.getDisplay(this);

break;
}
break;
case Command.EXIT:
destroyApp(false);
notifyDestroyed();
break;
case Command.BACK:
pantalla.setCurrent(elmenu);
limpiar();
break;
case Command.OK:


if (c == cmdGuardar)
{
this.c.nombre = nombre.getString();
this.c.descuento = Long.parseLong(descuento.getString());
this.c.moneda = "Vacio";

if(moneda.isSelected(0))
{
elmenu.setTitle(moneda.getString(0));
this.c.moneda = moneda.getString(0);
this.c.pesos = this.c.descuento*13;
}
else if(moneda.isSelected(1))
{
elmenu.setTitle(moneda.getString(1));
this.c.moneda = moneda.getString(1);
this.c.pesos = this.c.descuento*18;
}
else if(moneda.isSelected(2))
{
elmenu.setTitle(moneda.getString(2));
this.c.moneda = moneda.getString(2);
this.c.pesos = this.c.descuento*2;
}

this.c.agregar();
limpiar();
pantalla.setCurrent(elmenu);
}
else if(c == cmdEliminar)
{
this.c.nombre = nombre2.getString();
frmResultados.delete(itemResultados);
itemResultados = frmResultados.append(this.c.eliminar());
limpiar();
pantalla.setCurrent(frmResultados);
}
else if(c == cmdBuscar)
{
this.c.nombre = nombre3.getString();
frmResultados.delete(itemResultados);
itemResultados = frmResultados.append(this.c.buscar());
limpiar();
pantalla.setCurrent(frmResultados);
}

break;
}

}
void limpiar()
{
nombre.setString("");
nombre2.setString("");
nombre3.setString("");
descuento.setString("");
// txtcantidadmoneda.setString("");

}

class Cliente
{
public String clave;
public String nombre;
private long descuento;
private long pesos;
private String moneda;
//Agregar
public void agregar()
{
RecordStore rs = null;
try
{
rs = RecordStore.openRecordStore(BD,false);
RecordEnumeration registros = rs.enumerateRecords(null, null, false);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream os = new DataOutputStream(baos);

try
{
os.writeUTF(nombre);
os.writeLong(descuento);

os.writeLong(pesos);

os.writeUTF(moneda);

os.flush();
}
catch (IOException ioe) {}

byte[] b = baos.toByteArray();
try
{
rs.addRecord(b, 0, b.length);
}
catch (RecordStoreException rse) {}
rs.closeRecordStore();
}
catch( RecordStoreException e ){}
}
//Eliminar
public String eliminar()
{
int indice;
RecordStore rs = null;
String texto = "No se encontro el registro";
try
{
rs = RecordStore.openRecordStore(BD, false);
RecordEnumeration registros = rs.enumerateRecords(null, null, false);
while (registros.hasNextElement())
{
indice=registros.nextRecordId();
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(rs.getRecord(indice));
DataInputStream is = new DataInputStream(bais);
try
{
clave = is.readUTF();
}
catch (EOFException eofe) {}
catch (IOException ioe) {}
if (clave.equals(this.nombre))
{
try
{
rs.deleteRecord(indice);
texto = "El registro"+indice+"ha sido eliminado";
}
catch(InvalidRecordIDException e){}
}
}
catch (RecordStoreException e) {}
}
rs.closeRecordStore();
}
catch( RecordStoreException e ){}
return texto;
}
//Buscar

public String buscar()
{
String texto = "";
String elnornbre;
String moneda;

long cantidad;
long pesos;
boolean eureka = false;
RecordStore rs = null;
int indice;
try
{
rs = RecordStore.openRecordStore(BD, false);
RecordEnumeration registros = rs.enumerateRecords(null, null, false);
while (registros.hasNextElement())
{
indice=registros.nextRecordId();
try
{
ByteArrayInputStream bais = new ByteArrayInputStream(rs.getRecord(indice));
DataInputStream is = new DataInputStream(bais);
try
{
elnornbre = is.readUTF();
cantidad = is.readLong();
pesos = is.readLong();
moneda = is.readUTF();

if(this.nombre.equals("*") || this.nombre.equals("ALL"))
{
texto += "INDICE: "+indice+"\nCLIENTE: "+elnornbre+"\nCANTIDAD:"+cantidad+"\nMoneda: " +moneda+"\nPesos: " +pesos+"\n\n";
eureka = true;
}
else
{
if (elnornbre.equals(nombre))
{
texto += "INDICE: "+indice+ "\nCLIENTE: " +elnornbre+"\nCANTIDAD:"+cantidad+"\nMoneda: " +moneda+"\nPesos: " +pesos+"\n\n";
eureka = true;
}
}
}
catch (EOFException eofe) {}
catch (IOException ice) {}
bais.reset();
}
catch (RecordStoreException e) {}
}
rs.closeRecordStore();
}
catch( RecordStoreException e ){}
if (!eureka)
texto = "No se encontro el registro";
return texto;
}
}

}//clase Cliente

sábado, 26 de marzo de 2011

codigo de la aplicacion

import java.io.*;

import javax.microedition.midlet.*;


import javax.microedition.io.*;
import javax.microedition.lcdui.*;
public class Datos extends MIDlet implements CommandListener {
Display display = null;
List menu = null;
TextBox input = null;
TextBox t = null;
private String url1 = "http://rodrix.freeiz.com/personal";
private String url2 = "http://rodrix.freeiz.com/adicional";
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 Datos() { }
public void startApp() throws MIDletStateChangeException {

display = Display.getDisplay(this);
menu = new List("Menu Items", Choice.IMPLICIT);
menu.append("Informacion Personal", null);

menu.append("Informacion Adicional", null);
menu.addCommand(exitCommand);
menu.setCommandListener(this);


mainMenu();

}

void mainMenu() {

display.setCurrent(menu);

currentMenu = "Main";

}

public void misDatos() {

try {
download(url1);

} catch(IOException e) {

System.out.println("IOException: " + e);

}


}


public void datosAdicionales(){

try {
download1(url2);

} catch(IOException e) {

System.out.println("IOException: " + e);

}


}
private void download (String url1) throws IOException {

StringBuffer b = new StringBuffer();

InputStream is = null;

HttpConnection c = null;


try {

long len = 0;

int ch = 0;


c = (HttpConnection)Connector.open(url1);

is = c.openInputStream();


while((ch = is.read()) != -1) {
b.append((char)ch);

}
t = new TextBox("Informacion...", b.toString(), 1024, 0);

t.addCommand(backCommand);

t.setCommandListener(this);


} finally {

if (is != null)

is.close();

if (c != null)

c.close();
}

display.setCurrent(t);

}

private void download1 (String url2) throws IOException {

StringBuffer b = new StringBuffer();

InputStream is = null;

HttpConnection c = null;


try {

long len = 0;

int ch = 0;


c = (HttpConnection)Connector.open(url2);

is = c.openInputStream();


while((ch = is.read()) != -1) {

b.append((char)ch);
}

t = new TextBox("Adicional...", b.toString(), 1024, 0);

t.addCommand(backCommand);

t.setCommandListener(this);

} finally {

if (is != null)

is.close();

if (c != null)

c.close();
}

display.setCurrent(t);

}

public void testItem1() {
misDatos();

currentMenu = "informacion";

}

public void testItem2() {
datosAdicionales();

currentMenu = "Datos adicionales";

}

public void commandAction(Command c, Displayable d) {

String label = c.getLabel();

if (label.equals("Exit")) {
destroyApp(true);

} else if (label.equals("Back")) {
mainMenu();
if (currentMenu.equals("Informacion personales") || currentMenu.equals("Informacion adicional")) {


}
} else {

List down = (List)display.getCurrent();

switch (down.getSelectedIndex()) {

case 0: testItem1();break;

case 1: testItem2();break;

}

}

}


public void pauseApp() {

}


public void destroyApp(boolean incondicional) {

}

}


martes, 1 de marzo de 2011


CODIGO

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

public class tarjeta extends MIDlet implements CommandListener {
private Display display;
private Command salir;
private Canvas micanvas;

//Constructor
public tarjeta() {

//Cogemos el display
display=Display.getDisplay(this);

//Creamos la pantalla principal
micanvas = new Canvas() {
private int width;
private int height;

public void paint (Graphics g){
width=getWidth();
height=getHeight();

//Pintamos la pantalla de negro
g.setColor(0,0,0);
g.fillRect(0,0,width,height);

//Leemos una imagen desde un fichero y la mostramos
try {
Image imagen=Image.createImage("/logo.png");
g.drawImage(imagen,width/2,height/2,(Graphics.VCENTER | Graphics.HCENTER));
g.setColor(255,255,255);
//g.setStrokeStyle(Graphics.SOLID);
g.drawString("Ek Rodrigo rodris_tiger101@hotmail.com",10,10,(Graphics.BASELINE |
Graphics.LEFT));
g.drawString("",10,10,(Graphics.BASELINE |
Graphics.LEFT));



} catch (java.io.IOException e) {
g.setColor(255,255,255);
g.setStrokeStyle(Graphics.SOLID);
g.drawString("Fallo al leer logo.png",0,height/2,(Graphics.BASELINE | Graphics.LEFT));

}
}//fin del metodo paint
};
//Creamos el comando salir
salir=new Command("Salir",Command.EXIT,3);

//añadimos el comando al Canvas y activamos el oyente
micanvas.addCommand(salir);
micanvas.setCommandListener(this);
}

//Metodo que se llama cuando pasamos de Pausado a Activo
protected void startApp( ) {
display.setCurrent(micanvas);
}

//Metodo que se llama cuando pasamos de Activado a Pausado
protected void pauseApp( ) {
display.setCurrent(micanvas);
}

//Metodo que se llama cuando se destruye el midlet
protected void destroyApp(boolean incondicional) {
}

//Metodo para el tratamiento de datos del teclado
public void commandAction(Command c, Displayable d) {
//Miramos si nos salimos o mostramos alerta
if (c==salir) {
destroyApp(true);
notifyDestroyed();
} else System.out.println("Otro comando pulsado");
}
}

miércoles, 9 de febrero de 2011

MI LINK: http://rodrix.freeiz.com/

mi equipo somos

Mirtha Chan Pacheco y Ek Martin Rodrigo

viernes, 4 de febrero de 2011

martes, 1 de febrero de 2011

martes, 11 de enero de 2011

CELULAR


Sony Ericsson


W200


CLDC= 1.1


MIDP= 2.0