martes, 12 de abril de 2011

Direccion de base de datos

http://juanandres.comeze.com/cambio/cambio.php?rmoneda=yen

lunes, 11 de abril de 2011

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

public class V2Cambio extends MIDlet implements CommandListener {
static final String BD = "datos";
private String url = "http://extremadamenteeinnecesariamentelargo.web44.net/cambio/cambio.php?rmoneda=";
// private String url = "http://127.0.0.1/cambio/cambio.php";
String nc = "Dolares";
String tmoneda = "Dolar";
private Command cmdVer;

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

private ChoiceGroup moneda;
private ChoiceGroup pesos;
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 Form frmConeccion;
private Command cmdRegresar;
private TextField txtcantidadmoneda;

public V2Cambio() {
//.........................
// Prepara Display
//.........................
pantalla = Display.getDisplay(this);
//.........................
// Prepara Base de Datos
//.........................
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 );
}

/*
* ----------------------
* menu principal
* ----------------------
*/
String opciones[] = {"Añadir", "Eliminar", "Busqueda", "Conexion a internet para verificar cambio."};
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);

//-----------------------
//Añadir
//-----------------------
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("Euros", null);
moneda.append("Yenes", null);
moneda.append("Dolares", null);

frmAgregar.append(moneda);

//-------------------
//Eliminar
//-------------------
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);

//-----------------------
//Buscar
//-----------------------
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);

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

//----------------------
//Acerca De...
//----------------------

cmdVer = new Command("Ver", Command.OK,2);
frmConeccion = new Form ("Conectado con Dolares");

txtcantidadmoneda = new TextField("Dolares:","",10,TextField.ANY);
pesos = new ChoiceGroup("Tipo Moneda", Choice.EXCLUSIVE);
pesos.append("Euros", null);
pesos.append("Yenes", null);
pesos.append("Dolares", null);
frmConeccion.addCommand(cmdVer);

frmConeccion.append(pesos);
frmConeccion.append(txtcantidadmoneda);
frmConeccion.addCommand(cmdCancelar);
frmConeccion.setCommandListener(this);

}



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

//////
public void download (String url) throws IOException{
txtPesos = new TextField("Nombre", "Juan Puch", 10, TextField.ANY);


StringBuffer b= new StringBuffer();
InputStream is=null;
HttpConnection c=null;
String mostrar = "";
try {
long len =0;
int ch=0;

c= (HttpConnection)Connector.open(url);
is = c.openInputStream();
while ((ch=is.read()) !=-1){
b.append((char)ch);

}
txtcantidadmoneda.setString( b.toString().substring(0, 6));


} finally {
if(is !=null)
is.close();
if(c !=null)
c.close();
}
//pantalla.setCurrent(t);
}
//////

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void commandAction(Command c, Displayable s){



if(c == cmdVer)
{


if(pesos.isSelected(0))
{

frmConeccion.setTitle("Conectado con Dolares");
url = "http://extremadamenteeinnecesariamentelargo.web44.net/cambio/cambio.php";
// url = "http://127.0.0.1/cambio/cambio.php";

try{
download(url);
} catch(IOException e){
System.out.println("IOException" + e);
}

}
else if(pesos.isSelected(1))
{
pantalla.setCurrent(frmConeccion);
frmConeccion.setTitle("Conectado con Euros");
url = "http://extremadamenteeinnecesariamentelargo.web44.net/cambio/cambio.php?rmoneda=euro";
// url = "http://127.0.0.1/cambio/cambio.php?rmoneda=euro";
try{
download(url);
} catch(IOException e){
System.out.println("IOException" + e);
}

}
else if(pesos.isSelected(2))
{

frmConeccion.setTitle("Conectado con Yens");
url = "http://extremadamenteeinnecesariamentelargo.web44.net/cambio/cambio.php?rmoneda=yen";
// url = "http://127.0.0.1/cambio/cambio.php?rmoneda=yen";

try{
download(url);
} catch(IOException e){
System.out.println("IOException" + e);
}

}
}

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(frmConeccion);

pantalla = Display.getDisplay(this);
try{
download(url);
} catch(IOException e){
System.out.println("IOException" + e);
}
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

viernes, 8 de abril de 2011

Tarea



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

public class Clientepajaro 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 Clientepajaro() {
//.........................
// Prepara Display
//.........................
pantalla = Display.getDisplay(this);
//.........................
// Prepara Base de Datos
//.........................
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 );
}

/*
* ----------------------
* menu principal
* ----------------------
*/
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);

//-----------------------
//Añadir
//-----------------------
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);

//-------------------
//Eliminar
//-------------------
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);

//-----------------------
//Buscar
//-----------------------
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);

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

//----------------------
//Acerca De...
//----------------------

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

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




M I C O D I G O

import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
public class Principal extends MIDlet implements CommandListener {
Display display = null;

private String url = "http://extremadamenteeinnecesariamentelargo.web44.net/docs/datos-pajaro";
private String url2 = "http://extremadamenteeinnecesariamentelargo.web44.net/docs/datos-adicional";

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() { }
public void startApp() throws MIDletStateChangeException { display = Display.getDisplay(this);
menu = new List("Menu Items", Choice.IMPLICIT);
menu.append("Datos generales", null);
menu.append("Informacion Adicional", null);


menu.addCommand(exitCommand);
menu.setCommandListener(this);
mainMenu();

}
public void download (String url) throws IOException{
StringBuffer b= new StringBuffer();
InputStream is=null;
HttpConnection c=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);

} 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, Displayable d) {
String label = c.getLabel();
if (label.equals("Exit")) {
destroyApp(true);
}
if (label.equals("Back")) {
mainMenu();
if(currentMenu.equals("Datos generales") ||
currentMenu.equals("Informacion Adicional") ) {


}
} else {
List down = (List)display.getCurrent();
switch(down.getSelectedIndex()) {
case 0: testIteml();break;
case 1: testItem2();break;


}
}
}
}

martes, 1 de marzo de 2011

mi tarjeta


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("juan andres--------santamariajuan1958@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");
}
}

viernes, 4 de febrero de 2011

NUEVO URL

www.charrito-cuaco.site88.net

martes, 1 de febrero de 2011