How to override TextField functionality for specific class?

这一生的挚爱 提交于 2019-12-11 15:21:35

问题


I have KeyEvent.KEY_TYPED on my TextFields. 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 TextFields, can I override method for all TextFields at once, but only for current class I'm working on?


回答1:


public class NewTextField extends TextField {
     @Override
    public void paste() {
        super.paste();
        System.out.println("text pasted in");
    }
}

Use NewTextField as the textfield you want to have your paste feature.



来源:https://stackoverflow.com/questions/45961079/how-to-override-textfield-functionality-for-specific-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!