如何覆盖特定类的TextField功能? [英] How to override TextField functionality for specific class?
本文介绍了如何覆盖特定类的TextField功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 TextField
上有 KeyEvent.KEY_TYPED
。如果用户使用键盘快捷键粘贴数据,则会触发事件。但是如果用户右键单击鼠标粘贴它就不起作用。我找到了此解决方案解决了这个问题。但我有很多 TextField
s,我可以覆盖所有
s,但仅适用于我正在处理的当前课程? TextField的
方法
I have KeyEvent.KEY_TYPED
on my TextField
s. If user pastes data with keyboard shortcut, event gets triggered. But it doesn't work if user pastes with right click on mouse. I found this solution that solves this issue. But I have many TextField
s, can I override
method for all TextField
s at once, but only for current class I'm working on?
推荐答案
public class NewTextField extends TextField {
@Override
public void paste() {
super.paste();
System.out.println("text pasted in");
}
}
使用NewTextField作为要粘贴的文本字段功能。
Use NewTextField as the textfield you want to have your paste feature.
这篇关于如何覆盖特定类的TextField功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文