更改JTextfield的侦听器 [英] Change Listener for a JTextfield

查看:78
本文介绍了更改JTextfield的侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个从面板动态获取数据的程序,但是我的代码需要用户按Enter键才能更新数据.是否存在一个更改侦听器或其他侦听器,这些侦听器或其他侦听器可以随时更新来自Jtextfield的数据?谢谢!

I made a program that dynamically gets data from a Panel but my code needs the user to hit the enter button for the data to be updated. Is there a change listener or other listeners that can update the data from a Jtextfield whenever it is updated? Thanks!

推荐答案

只需将侦听器添加到文本字段中,以便它可以跟踪文本更改的时间

Just add a listener to the textfield so that it tracks when the text changes

textfieldName.getDocument().addDocumentListener(new DocumentListener() {
    // implement the methods
});

这篇关于更改JTextfield的侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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