开发者

Blackberry RichTextField validation

开发者 https://www.devze.com 2023-02-17 22:05 出处:网络
I have created a RichTextField and I want to have it allo开发者_如何学Cw only integer values. How can I make that happen?You can try something like this:

I have created a RichTextField and I want to have it allo开发者_如何学Cw only integer values. How can I make that happen?


You can try something like this:

public class MyRichTextField extends RichTextField {

    public MyRichTextField() {
        super();
    }

    public void setText(String text) {
        try {
            int x = Integer.parseInt(text);
            super.setText("" + x);
        } catch (NumberFormatException e) {
            // the text is not a number
            super.setText("");
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消