Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Universidad de Jaén
E.U.P. Linares
Dpto. Telecomunicaciones
Área de Ingeniería Telemática
Ø Introducción
Clase Display y Displayable
Clase Command y CommandListener
Command Displayable
Item
CustomItem Spacer
Void setCommandListener(CommandListener l)
Establece un listener parra la captura de eventos.
Command cmd;
cmd =new Command(Etiqueta, Tipo, Prioridad)
INICIO SEGUNDO
public Tiza(){
pantalla=Display.getDisplay(this);
salir=new Command("Salir",Command.EXIT,1);
// FORMULARIO 1
formulario1=new Form(“INICIO");
formulario1.setCommandListener(this);
sigue=new Command("Sigue",Command.SCREEN,1);
formulario1.addCommand(sigue);
formulario1.addCommand(salir);
// FORMULARIO 2
formulario2=new Form(“SEGUNDO");
formulario2.setCommandListener(this);
atras=new Command("Atrás",Command.BACK,1);
formulario2.addCommand(atras);
formulario2.addCommand(salir);
}
Alert(String titulo);
Alert(String titulo, String textoalerta, Image imagen, AlertType tipo);
Tipos de alertas:
ALARM Aviso de una petición previa.
CONFIRMATION Indica la aceptación de una acción.
ERROR Indica que ha ocurrido un error.
INFO Indica algún tipo de información.
WARNING Indica que puede ocurrir algún problema.
AlertType.CONFIRMATION.playSound(display)
public Tiza(){
pantalla=Display.getDisplay(this);
formulario=new Form(“INICIO");
formulario.setCommandListener(this);
salir=new Command("Salir",Command.EXIT,1);
modal=new Command(“Modal",Command.SCREEN,1);
nomodal=new Command(“No Modal",Command.SCREEN,1);
formulario.addCommand(salir);
formulario.addCommand(modal);
formulario.addCommand(nomodal);
// ALERTA1
alerta1=new Alert("Modal", "Esta es una ALERTA MODAL", null, AlertType.INFO);
alerta1.setTimeout(Alert.FOREVER);
// ALERTA2
alerta2=new Alert("NO-Modal", "Esta es una ALERTA NO MODAL", null, AlertType.INFO);
alerta2.setTimeout(5000);
}
void set(int pos, String txt, Image im) Reemplaza el elemento pos.
// LISTA
String opciones[]={“Opción1”,”Opción2”,”Opción3”};
menu=new List(“LISTA EXCLUSIVA",List.EXCLUSIVE,opciones,null);
salir=new Command(“Atrás",Command.EXIT,1); LISTA EXCLUSIVA
salvar=new Command(“Salvar",Command.ITEM,1);
menu.setCommandListener(this);
menu.addCommand(salir);
menu.addCommand(salvar);
}
public void commandAction(Command c, Displayable d){
if (c==salvar){
int opcionelegida=menu.getSelectedIndex();
// Salvar opciones en memoria persistente
}
if (c==salir){
destroyApp(true);
}
}
INGENIERÍA DE TELECOMUNICACIÓN DPTO. TELECOMUNICACIONES -- ÁREA DE INGENIERÍA TELEMÁTICA
APLICACIONES PARA TELEFONÍA MÓVIL DESARROLLO DE APLICACIONES
public Tiza(){
pantalla=Display.getDisplay(this);
// LISTA
salir=new Command(“Salir",Command.EXIT,1);
salvar=new Command(“Salvar",Command.ITEM,1);
menu=new List(“LISTA MULTIPLE",List.MULTIPLE);
menu.insert(menu.size(),”Opción1”,null);
menu.insert(menu.size(),”Opción2”,null);
menu.insert(menu.size(),”Opción3”,null);
menu.setCommandListener(this);
menu.addCommand(salir);
menu.addCommand(salvar);
}
EJEMPLO:
TextBox caja=new TextBox(“Contraseña”,””,30,TextField.NUMERIC|TextField.PASSWORD)
void insert(int num, Item item) Inserta un Item justo antes del que
ocupa la posición num.
Item
CustomItem Spacer
void notifyStateChanged()
void setItemCommandListener(ItemCommandListener i)
Modo: DATE
TIME
DATE_TIME
Tipo: EXCLUSIVE
IMPLICIT
MULTIPLE
void set(int pos, String txt, Image im) Reemplaza el elemento pos.
MÉTODOS
getGameAction paint
CustomItem
getInteractionModes pointerDragged (0,0)
getMinContentHeight pointerPressed
getMinContentWidth pointerReleased
getPrefContentHeight repaint
getPrefContentWidth showNotify
hideNotify sizeChanged
Invalidate traverse
keyPressed traverseOut
keyReleased
keyRepeated
INGENIERÍA DE TELECOMUNICACIÓN DPTO. TELECOMUNICACIONES -- ÁREA DE INGENIERÍA TELEMÁTICA
APLICACIONES PARA TELEFONÍA MÓVIL DESARROLLO DE APLICACIONES
Display
Command Displayable
Métodos Descripción
boolean hasRepeatEvents() Indica si el MID es capaz de detectar la repetición de
teclas.
String getKeyName(int codigo) Devuelve una cadena de texto con el nombre del código
asociado.
void keyPressed(int codigo) Se invoca cuando se pulsa una tecla.
void keyReleased(int codigo) Se invoca cuando se suelta una tecla.
void keyRepeated(int codigo) Se invoca cuando se deja pulsada una tecla.
Métodos Descripción
boolean hasPointerEvents() Devuelve true si el dispositivo posee algún puntero.
boolean hasPointerMotionsEvents() Devuelve true si el dispositivo puede detectar acciones
como pulsar, arrastrar y soltar puntero.
void pointerDragged() Se invoca cuando se arrastra el puntero.
void pointerPressed() Se invoca cuando se haced click.
void pointerReleased() Se invoca cuando se deja pulsado el puntero.
Image imgtemp=Image.createImage(ancho,alto);
Graphics g=imgtemp.getGraphics().
MÉTODOS
GRAPHICS
translate(int x, int y)
Cambia el origen de
coordenadas al punto
definido.
GRAPHICS
setColor(int RGB)
setColor(int R, int G, int B)
Para seleccionar un color.
8 bits para cada
componente.
Font fuente=Font.getFont
(FACE_SYSTEM,STYLE_PLAIN,SIZE_LARGE);
g.setFont(fuente);
g.drawString(
BASELINE|CENTER
Líneas Arcos
g.setColor(0,0,0); g.drawArc(x,y,ancho,alto,gr-inicio,gr-final);
g.drawline(x1,y1,x2,y2); g.fillArc(x,y,ancho,alto,gr-inicio,gr-final);
Rectángulos
g.setColor(0,0,0);
g.drawRect(x,y,ancho,alto);
g.fillRect(x,y,ancho,alto);
g.drawRoundRect(x,y,ancho,alto,arcancho,arcalto);
g.fillRoundRect(x,y,ancho,alto,arcancho,arcalto);
Image im=Image.createImage(75,25);
g.drawImage(im,0,0,TOP|LEFT);
g.drawImage(im,x,y,anchorpoint);