Java me 如何大写lwuit文本字段中的首字母?

Java me 如何大写lwuit文本字段中的首字母?,java-me,lwuit,lwuit-textfield,Java Me,Lwuit,Lwuit Textfield,我已尝试使用以下代码将文本字段中的第一个字母大写:- Form f = new Form(); TextField firstname = new TextField(); firstname.setConstraint(TextField.INITIAL_CAPS_SENTENCE); f.addComponent(firstname); f.show(); 但这是行不通的 我错过了什么?有人能提出一个正确的方法来实现它吗 注意:我使用的是LWUIT 1.5 已编辑 在Shai的帮助下,我终

我已尝试使用以下代码将文本字段中的第一个字母大写:-

Form f = new Form();
TextField firstname = new TextField();
firstname.setConstraint(TextField.INITIAL_CAPS_SENTENCE);
f.addComponent(firstname);
f.show();
但这是行不通的

我错过了什么?有人能提出一个正确的方法来实现它吗

注意:我使用的是LWUIT 1.5

已编辑

在Shai的帮助下,我终于做到了这一点

public void insertChars(String c) {
    super.insertChars(c); //To change body of generated methods, choose Tools | Templates.
    if(super.getText()!=null && super.getText().length()>0){      
        super.setText((super.getText().substring(0,1).toUpperCase())+super.getText().substring(1, super.getText().length()));
    }else{
        super.setText(super.getText());
    }
}

您是否有可能使用qwerty J2ME设备?如果是这样,这将不起作用,因为这只适用于事物的本机端


您需要派生
TextField
并重写insertChar()来实现此功能。

是的,我使用的是qwerty设备。正如您所提到的,我重写了insertChar()以实现这一点。谢谢你,谢伊:)