void (DocumentEvent e, JTextField textField) { if (e.getType() == DocumentEvent.EventType.INSERT) { String text = textField.getText(); if (isMvnDependency(text)) { DocumentBuilder builder = JavaXmlDocumentKt.createDocumentBuilder(); try { Document document = builder.parse(new InputSource(new StringReader(text))); String mavenCoordinates = extractMavenCoordinates(document); if (mavenCoordinates != null) { textField.setText(mavenCoordinates); } } catch (SAXException | IOException ignored) { } } } }