Что не так? Не проходит пункт Метод getPlainText() должен возвращать текст из документа со всеми html тегами. Что сделать, не понимаю что вале не нравится. Нужно реализовать метод String getPlainText() в классе Controller. Сделал вроде все по заданию.
package com.javarush.task.task32.task3209;
import com.javarush.task.task32.task3209.listeners.FrameListener;
import com.javarush.task.task32.task3209.listeners.TabbedPaneChangeListener;
import com.javarush.task.task32.task3209.listeners.UndoListener;
import javax.swing.*;
import javax.swing.text.html.HTMLDocument;
import javax.swing.undo.UndoManager;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class View extends JFrame implements ActionListener {
private Controller controller;
private JTabbedPane tabbedPane = new JTabbedPane();
private JTextPane htmlTextPane = new JTextPane();
private JEditorPane plainTextPane = new JEditorPane();
private UndoManager undoManager = new UndoManager();
private UndoListener undoListener = new UndoListener(undoManager);
public Controller getController() {
return controller;
}
public void setController(Controller controller) {
this.controller = controller;
}
public void init() {
initGui();
FrameListener frameListener = new FrameListener(this);
addWindowListener(frameListener);
setVisible(true);
}
public void exit() {
controller.exit();
}
public View() throws HeadlessException {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
ExceptionHandler.log(e);
}
}
public void initMenuBar() {
JMenuBar menuBar = new JMenuBar();
MenuHelper.initFileMenu(this, menuBar);
MenuHelper.initEditMenu(this, menuBar);
MenuHelper.initStyleMenu(this, menuBar);
MenuHelper.initAlignMenu(this, menuBar);
MenuHelper.initColorMenu(this, menuBar);
MenuHelper.initFontMenu(this, menuBar);
MenuHelper.initHelpMenu(this, menuBar);
getContentPane().add(menuBar, BorderLayout.NORTH);
}
public void initEditor() {
htmlTextPane.setContentType("text/html");
JScrollPane scrollPane = new JScrollPane(htmlTextPane);
tabbedPane.addTab("HTML", scrollPane);
JScrollPane scrollPane2 = new JScrollPane(plainTextPane);
tabbedPane.addTab("Текст", scrollPane2);
tabbedPane.setPreferredSize(new Dimension(300, 300));
TabbedPaneChangeListener tabbedPaneChangeListener = new TabbedPaneChangeListener(this);
tabbedPane.addChangeListener(tabbedPaneChangeListener);
getContentPane().add(tabbedPane,BorderLayout.CENTER);
}
public void initGui() {
initMenuBar();
initEditor();
pack();
}
@Override
public void actionPerformed(ActionEvent actionEvent) {
}
public boolean isHtmlTabSelected() {
return tabbedPane.getSelectedIndex() == 0;
}
public void selectedTabChanged() {
}
public boolean canUndo() {
return undoManager.canUndo();
}
public UndoListener getUndoListener() {
return undoListener;
}
public boolean canRedo() {
return undoManager.canRedo();
}
public void undo() {
try {
undoManager.undo();
} catch (Exception e) {
ExceptionHandler.log(e);
}
}
public void redo() {
try {
undoManager.redo();
} catch (Exception e) {
ExceptionHandler.log(e);
}
}
public void resetUndo() {
undoManager.discardAllEdits();
}
public void selectHtmlTab() {
tabbedPane.setSelectedIndex(0);
resetUndo();
}
public void update() {
HTMLDocument document = controller.getDocument();
htmlTextPane.setDocument(document);
}
public void showAbout() {
JOptionPane.showMessageDialog(getContentPane(), "Version 1.0", "About", JOptionPane.INFORMATION_MESSAGE);
}
}