[英]Custom text input field in J2ME
I'm currently extending from CustomItem
and creating my own TextField
, is there any way that I can type in it and be able to retrieve that later? 我目前正在从
CustomItem
并创建自己的TextField
,我可以通过任何方式键入它并在以后检索它吗?
The code I have right now is very basic, just a class extending from CustomItem
, here's the code : 我现在拥有的代码非常基础,只是从
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);
}
}
Yes you can do it, theoretically. 是的,理论上您可以做到。
But it is a lot of work, as you need to write all the code to handle keystrokes, and write your own virtual keyboard. 但这是很多工作,因为您需要编写所有代码来处理击键,并编写自己的虚拟键盘。
An alternative is to use a library from somebody who has done all the work for you. 一种替代方法是使用已经为您完成所有工作的人员提供的图书馆。 For example I know it is possible with LWUIT Library.
例如,我知道使用LWUIT库是可能的。 But these libraries are also quite complex to use, and Java-ME is a shrinking platform.
但是这些库的使用也相当复杂,并且Java-ME是一个不断缩小的平台。 So I don't think I can recommend it today.
因此,我认为我今天不能推荐它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.