Code example for JTextComponent

Methods: getDocument

0
            @Override public void stateChanged(ChangeEvent e) { notifyListeners(); }
        }); 
    } 
 
    protected final void registerValidableComponent(JTextComponent component) {
        component.getDocument().addDocumentListener(new DocumentListener() {
            @Override public void removeUpdate(DocumentEvent e) { notifyListeners(); }
            @Override public void insertUpdate(DocumentEvent e) { notifyListeners(); }
            @Override public void changedUpdate(DocumentEvent e) { notifyListeners(); }
        }); 
    } 
 
    protected abstract ImageryInfo getImageryInfo(); 
 
    protected static String sanitize(String s) {
        return s.replaceAll("[\r\n]+", "").trim();
    } 
 
    protected final String getImageryName() {
        return sanitize(name.getText());