como o aparelho qtek 9090 nao esta colaborando com o textfield, pois o mesmo “estica” o componente para 5 linhas…ficando horrivel na tela…
por isso usando o customitem…estou arranhando a criacao do componente textfield…logico que é dificil e sozinho nao irei conseguir…porem com a ajuda da galera…quem sabe nao sai um projeto legal…
segue a minha classe…só que na emulacao do qwerty os eventos de teclas foram disparados, mas ao colocar no aparelho…nao funcionou nada…como se nao tivesse teclando nada…esse é o primeiro desafio nosso…ok
A Classe LTextField pode ser importada na paleta de Componentes Custom no netbeans…
ok…espero que alguem se interesse pelo assunto…ou quem ja fez mostra ai para nós…obrigado…
/*
- LTextField.java
- Created on 17 de Outubro de 2007, 10:58
- To change this template, choose Tools | Template Manager
- and open the template in the editor.
*/
package principal;
import java.util.Vector;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
/**
*
-
@author Clayton Ivan */ public class LTextField extends CustomItem{ private int largura; private int altura; private String texto; private Graphics canvas;
/** Creates a new instance of LTextField */ public LTextField(int altura, int largura) { super(“LyTextField”); this.largura = largura; this.altura = altura;
}
public void setTexto(String texto){ this.texto = texto; }public String getTexto(){ return texto; }
protected int getMinContentWidth() { return largura; }
protected int getMinContentHeight() { return altura; }
protected int getPrefContentWidth(int i) { return largura; }
protected int getPrefContentHeight(int i) { return altura; }
protected void paint(Graphics g, int w, int h) { canvas = g; g.setColor(255, 255, 255); g.fillRect(0, 0, w-1, h-1);g.setColor(0, 0, 0); g.drawLine(0, altura, w, altura); if (texto != null) g.drawString(texto, 3, 2, 0); g.drawRect(0, 0, w-1, h-1); g.setStrokeStyle(g.HCENTER);
}
protected void keyPressed(int keyCode) {
texto = texto + "press: " +String.valueOf(keyCode);repaint();
}
protected void keyReleased(int keyCode){
System.out.println(keyCode);texto = texto + "rele: " + String.valueOf(keyCode); String caracter = CodKeys.qTek_CaracterDigitado(new Integer(keyCode)) ; if (caracter != null) texto = texto + caracter; repaint();
}
protected boolean traverse(int dir, int viewportWidth, int viewportHeight, int[] visRect_inout ) {
boolean retorno = false;if (dir == Canvas.UP) { retorno = false; System.out.println("Up"); } else if (dir == Canvas.LEFT) { retorno = true; System.out.println("left"); } else if (dir == Canvas.DOWN) { retorno = false; System.out.println("Down"); } else if (dir == Canvas.RIGHT){ retorno = true; System.out.println("Rig"); } else retorno = true; System.out.println(retorno); return retorno;
}
}
Criacao de uma nova classe
import java.util.Hashtable;
/**
*
-
@author Clayton Ivan
*/
public class CodKeys {/** Creates a new instance of CodKeys */ public CodKeys() { }
/**
-
Configuracao de teclas para o modelo qTek 9090 (status nao concluido) */ public static String qTek_CaracterDigitado(Integer keyValue){ final char[] charset = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789’”.toCharArray(); final int[] codigoTecla = new int[65]; codigoTecla[0] = 65; Hashtable hashKey = new Hashtable(); hashKey.put(new Integer(65), new String(“A”)); hashKey.put(new Integer(97), new String(“a”));
return (String)
hashKey.get(keyValue);
}
-
}