嘿,我制作了一个程序,您可以在其中输入您的昵称,并且该昵称用于从网址读取图像。有什么方法可以做到这一点,例如,当我输入我的 JTextField 昵称“jeb_”时,它会同时刷新并更改 JLabel 以加载新图像,然后再按按钮执行此操作?
最佳答案
Is there any way to make it when i for example type in my JTextField nickname "jeb_" it will refresh and change JLabel in the same time
您将一个 DocumentListener
添加到 JTextField
的 Document
中。每次添加(或删除)角色时都会生成一个事件。
阅读 Swing 教程中关于 Listener For Changes on a Document 的部分了解更多信息和帮助您入门的工作示例。
关于java - 读取 JTextField 上的生命周期中输入的内容,并同时刷新 JLabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61159517/