覆盖 JTextField 的 getText
我希望覆盖 getText()
以便它可以返回空值而不是空白值。我注意到 getText()
是 JTextComponent
的一部分,但我无法成功覆盖它。获得所需结果的最佳方法是什么?
I wish to overwrite getText()
so that it can return a null value instead of a a blank value. I noticed that getText()
is a part of JTextComponent
and I've been unable to successfully overwrite it. What is the best way to get the desired result?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以子类化
JTextField
并重写getText
方法,如此或者您可以内联重写,如此
You can subclass
JTextField
and override thegetText
method, as suchOr you can inline the override, as such