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?
            Asked
            
        
        
            Active
            
        
            Viewed 123 times
        
    0
            
            
         
    
    
        Alyona
        
- 1,682
- 2
- 21
- 44
- 
                    Have you tried checking if the parent class of your Textfield is matching that class? – smukamuka Aug 30 '17 at 13:00
1 Answers
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.
 
    
    
        THe_strOX
        
- 687
- 1
- 5
- 16
- 
                    And what can I do with existing `TextField` that are originally there from .fxml file? – Alyona Aug 30 '17 at 13:24
- 
                    @Alyona I would assume the intention is to replace `` with ` – James_D Aug 30 '17 at 13:29` whenever you need the additional functionality. 
- 
                    I add through code only few `TextField`, most of them are placed in .fxml. – Alyona Aug 30 '17 at 13:32
- 
                    1@Alyona Yes, exactly, that's what I meant. Use `` in your FXML instead of ` – James_D Aug 30 '17 at 13:32`.