当前位置: 技术问答>java相关
怎么用JTextField的setText()方法显示数字.
来源: 互联网 发布时间:2017-03-23
本文导语: 读取数据库后返回来的是int型数值, result = statement.executeQuery(query); result.next(); int out = result.getInt(1); 想在JTextField中显示,该怎么办?????? 说详细点好吗? | 也可以用字符~ String temp; char ch; w...
读取数据库后返回来的是int型数值,
result = statement.executeQuery(query);
result.next();
int out = result.getInt(1);
想在JTextField中显示,该怎么办??????
说详细点好吗?
result = statement.executeQuery(query);
result.next();
int out = result.getInt(1);
想在JTextField中显示,该怎么办??????
说详细点好吗?
|
也可以用字符~
String temp;
char ch;
while(out>0)
{
ch=Character.forDigit(out%10,10);
out=out/10;
temp+=ch;
}
String temp;
char ch;
while(out>0)
{
ch=Character.forDigit(out%10,10);
out=out/10;
temp+=ch;
}
|
number.toString()
|
result = statement.executeQuery(query);
result.next();
int out = result.getInt(1);
JTextField.setText(String.valueOf(out))
result.next();
int out = result.getInt(1);
JTextField.setText(String.valueOf(out))
|
setText(out.toString());
|
将数字转化为字符串
String.valueOf(x)
x为数字
String.valueOf(x)
x为数字