将值附加到JTextField吗? [英] Append value to JTextField?

查看:86
本文介绍了将值附加到JTextField吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Java中将值附加到JTextField中.像这样:

I want to append a value into a JTextField in Java. Something like:

String btn1="1"; 
textField.appendText(btn1);

推荐答案

我认为您会找到setText的答案.只需将当前值与新值结合起来即可:

I think you'll find setText is the answer. Just combine the current value with the new value:

textField.setText(textField.getText() + newStringHere); 

这篇关于将值附加到JTextField吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆