textbox类只接受Java中的整数 [英] A textbox class only accept integers in Java
本文介绍了textbox类只接受Java中的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想做一个textbox类只接受整数..
I just want to do a textbox class only accepts integers..
我做了一些事情,但我认为这还不够。
I have done something, but ı think it's not enough.
有人可以帮帮我吗?
谢谢...
Can anyone help me, please? Thanks...
import java.awt.TextField
public class textbox extends TextField{
private int value;
public textbox(){
super();
}
public textbox(int value){
setDeger(value);
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
推荐答案
我认为你错过了这里的一点提示,你的代码我仍然可以调用
textfield.setText(我不是数字);
I think you are missing the point here's a hint, with your code i can still call textfield.setText("i'm not a number");
这篇关于textbox类只接受Java中的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文