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("");
}
}
}
精彩评论