Handling text change events in JTextField and JLabel

JLabel : PropertyChangeListener

JTextField : DocumentListener

 import javax.swing.*;  
 import javax.swing.event.DocumentEvent;  
 import javax.swing.event.DocumentListener;  
 import java.beans.PropertyChangeEvent;  
 import java.beans.PropertyChangeListener;  
   
 public class TestClass {  
   JLabel mLabel = new JLabel("TEST");  
   JTextField mTextField = new JTextField("TEST");  
   
   TestClass() {  
     mLabel.addPropertyChangeListener(new MyChangeListener());  
     mTextField.getDocument().addDocumentListener(new MyDocumentListener());  
   }  
   
   private class MyChangeListener implements PropertyChangeListener {  
     @Override  
     public void propertyChange(PropertyChangeEvent evt) {  
       if ("text".equals(evt.getPropertyName())) {  
   
       }  
     }  
   }  
   
   private class MyDocumentListener implements DocumentListener {  
     @Override  
     public void insertUpdate(DocumentEvent e) {  
   
     }  
   
     @Override  
     public void removeUpdate(DocumentEvent e) {  
   
     }  
   
     @Override  
     public void changedUpdate(DocumentEvent e) {  
   
     }  
   }  
 }  

No comments:

Lognote - Log viewer, Android logcat viewer for Windows, Linux, Mac

android logcat viewer for Windows, Linux, Mac   https://github.com/cdcsgit/lognote Filtered log viewer Android logcat viewer, kotlin ...