问题
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