[英]Custom text input field in J2ME
我目前正在從CustomItem
並創建自己的TextField
,我可以通過任何方式鍵入它並在以后檢索它嗎?
我現在擁有的代碼非常基礎,只是從CustomItem
擴展的一個類,這是代碼:
public class AlaaTextField extends CustomItem{
public AlaaTextField(String label) {
super(label);
this.setPreferredSize(240, 20);
}
protected int getMinContentHeight() {
return 20;
}
protected int getMinContentWidth() {
return 240;
}
protected int getPrefContentHeight(int width) {
return 20;
}
protected int getPrefContentWidth(int height) {
return 240;
}
protected void paint(Graphics g, int w, int h) {
g.setColor(255, 255, 255);
g.fillRect(0, 0, w, h);
}
}
是的,理論上您可以做到。
但這是很多工作,因為您需要編寫所有代碼來處理擊鍵,並編寫自己的虛擬鍵盤。
一種替代方法是使用已經為您完成所有工作的人員提供的圖書館。 例如,我知道使用LWUIT庫是可能的。 但是這些庫的使用也相當復雜,並且Java-ME是一個不斷縮小的平台。 因此,我認為我今天不能推薦它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.