Could you please help me? I cannot pass the last condition.
Where could the problem be?
package com.codegym.task.task32.task3209;
import javax.swing.text.Document;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;
public class Controller {
private View view;
private HTMLDocument document; // responsible for the model
private File currentFile; //file that is opened in the editor
public Controller(View view) {
this.view = view;
}
public void init(){
}
public void exit(){
System.exit(0);
}
public HTMLDocument getDocument() {
return document;
}
public void resetDocument(){
if (document != null){
document.removeUndoableEditListener(view.getUndoListener());
}
Document editorKit = new HTMLEditorKit().createDefaultDocument();
editorKit.addUndoableEditListener(view.getUndoListener());
view.update();
}
public void setPlainText(String text){
resetDocument();
try {
StringReader sr = new StringReader(text);
new HTMLEditorKit().read(sr, document, 0);
}
catch (Exception e){
ExceptionHandler.log(e);
}
}
public String getPlainText(){
StringWriter stringWriter = new StringWriter();
try {
new HTMLEditorKit().write(stringWriter, document, 0, document.getLength());
} catch (Exception e) {
ExceptionHandler.log(e);
}
return stringWriter.toString();
}
public static void main(String[] args) {
View view = new View();
Controller controller = new Controller(view);
view.setController(controller);
view.init();
controller.init();
}
}