Hello. Faced such a problem, when I initialize an application, a DocumentListener is created, which is responsible for highlighting syntax, but after I load another document with:
private void readInFile(String fileName) { try { FileReader r = new FileReader(fileName); textArea.read(r,null); r.close(); currentFile = fileName; frame.setTitle(currentFile); changed = false; } catch(IOException e) { Toolkit.getDefaultToolkit().beep(); JOptionPane.showMessageDialog(textArea, "Editor can't find the file called "+fileName); } } The backlight stops working. I tried to make the creation in a separate method:
private void setDocumentListener() { textArea.getDocument().addDocumentListener(new DocumentListener() { //Здесь код } } I registered the call to the internalization and to the readInFile method so that it was called again when the new document was loaded, but this did not work. It also works only until the first download of the new document. Tell me what could be the reason and what am I doing wrong?
setDocumentListener? - Mikhail Vaysman