gt:         Lecture lecture = new Lecture(new File("tests/test2.xml"));
context: package com.experimental.memograph.ui.dialogs;
  
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.io.File;
  import java.net.URL;
  import java.util.LinkedList;
  
  import javax.swing.*;
  import javax.swing.event.HyperlinkEvent;
  
  import com.experimental.memograph.FlashCard;
  import com.experimental.memograph.Lecture;
  import com.experimental.memograph.ui.BreakThread;
  import com.experimental.memograph.MemorizationAlgorithm;
  
  import static javax.swing.event.HyperlinkEvent.EventType.ACTIVATED;
  
  
  public class MemorizationDialog extends JDialog implements ActionListener {
      JEditorPane question, answer;
  
      private JPanel pnlControlButtons;
      private JButton btnShowAnswer, btnRight, btnFalse, btnEdit;
  
      private FlashCard currentFlashCard;
      private MemorizationAlgorithm algorithm;
      private boolean isAnswerVisible;
  
      private Results result;
  
      public MemorizationDialog(Frame parent, LinkedList<FlashCard> cardsToMemorize) {
          super(parent);
  
          algorithm = new MemorizationAlgorithm(cardsToMemorize);
  
          createComponents();
          setNextCard();
  
          initializeLayout();
      }
  
      public Results getResult() {
          return result;
      }
  
      @Override
      public void actionPerformed(ActionEvent evt) {
          String cmd = evt.getActionCommand();
          switch (Actions.valueOf(cmd)) {
              case SHOW_ANSWER: {
                  showAnswer();
                  break;
              }
              case ANSWER_KNOWN: {
                  algorithm.rigthAnswer();
                  clearDisplay();
                  setButtonsEnabled(false);
                  BreakThread.callAfterBreak(this, "setNextCard", 1000);
                  break;
              }
              case ANSWER_UNKNOWN: {
                  algorithm.wrongAnswer();
                  setButtonsEnabled(false);
                  clearDisplay();
                  BreakThread.callAfterBreak(this, "setNextCard", 2500);
                  break;
              }
              case EDIT_CARD: {
                  FlashCard copy = (FlashCard) currentFlashCard.clone();
                  CardEditorDialog d = new CardEditorDialog(null, copy);
                  if (d.getResult() == JOptionPane.OK_OPTION) {
                      currentFlashCard.setAnswer(copy.getAnswer());
                      currentFlashCard.setQuestion(copy.getQuestion());
                      setCurrentFlashCard(currentFlashCard);
                      showAnswer();
                  }
                  break;
              }
              default: {
                  System.err.println("Logic to handle command '" + cmd +"' has not been implemented yet.");
              }
          }
      }
  
      public void setNextCard() {
          FlashCard nextFlashCard = algorithm.getNextCard();
  
          if (nextFlashCard != null) {
              setCurrentFlashCard(nextFlashCard);
              setButtonsEnabled(true);
          } else {
              result = Results.FINISHED;
              close();
          }
          isAnswerVisible = false;
      }
  
      private void setCurrentFlashCard(FlashCard flashCard) {
          currentFlashCard = flashCard;
          clearDisplay();
          question.setText(flashCard.getQuestion());
          btnShowAnswer.setText("Antwort anzeigen");
      }
  
      private void showAnswer() {
          answer.setText(currentFlashCard.getAnswer());
      }
  
      private void clearDisplay() {
          question.setText("");
          answer.setText("");
      }
  
      private void close() {
          setVisible(false);
      }
  
      private void setButtonsEnabled(boolean setEnabled) {
          Component[] children = pnlControlButtons.getComponents();
          for (Component c : children) {
              c.setEnabled(setEnabled);
          }
      }
  
      private void initializeLayout() {
          setModal(true);
  
          int maxWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().
                  getMaximumWindowBounds().width;
          int maxHeight = GraphicsEnvironment.getLocalGraphicsEnvironment().
                  getMaximumWindowBounds().height;
  
          setSize(maxWidth, maxHeight);
          setVisible(true);
      }
  
      private void createComponents() {
          setLayout(new BorderLayout());
          createMenuBar();
          createTextDisplay();
          createEvaluationButtons();
      }
  
      private void createMenuBar() {
          //TODO Method stub
      }
  
      private void createTextDisplay() {
          JPanel pnlCardContents = new JPanel();
          pnlCardContents.setLayout(new GridLayout(1,2));
  
          question = createCardDisplay();
          answer = createCardDisplay();
  
          pnlCardContents.add(new JScrollPane(question));
          pnlCardContents.add(new JScrollPane(answer));
  
          add(new JScrollPane(pnlCardContents), BorderLayout.CENTER);
      }
  
      private JEditorPane createCardDisplay() {
          JEditorPane card = new JEditorPane();
          card.setContentType("text/html");
          card.setFont(new Font("Serif", Font.PLAIN, 30));
          card.setBackground(Color.WHITE);
          card.setEditable(false);
          card.setOpaque(false);
          card.addHyperlinkListener(event -> {
              if (ACTIVATED.equals(event.getEventType())) {
                  openInExternalBrowser(event.getURL());
              }
          });
  
          return card;
      }
  
      private void openInExternalBrowser(URL url) {
          Desktop desktop = Desktop.getDesktop();
          try {
              desktop.browse(url.toURI());
          } catch (Exception ex) {
              ex.printStackTrace();
          }
      }
  
      private void createEvaluationButtons() {
          pnlControlButtons = new JPanel();
          pnlControlButtons.setOpaque(true);
          pnlControlButtons.setBackground(Color.WHITE);
  
          btnShowAnswer = new JButton("Antwort anzeigen");
          btnRight = new JButton("Richtig");
          btnFalse = new JButton("Falsch");
          btnEdit = new JButton("Bearbeiten");
  
          btnShowAnswer.setActionCommand(Actions.SHOW_ANSWER.toString());
          btnRight.setActionCommand(Actions.ANSWER_KNOWN.toString());
          btnFalse.setActionCommand(Actions.ANSWER_UNKNOWN.toString());
          btnEdit.setActionCommand(Actions.EDIT_CARD.toString());
  
          btnShowAnswer.addActionListener(this);
          btnRight.addActionListener(this);
          btnFalse.addActionListener(this);
          btnEdit.addActionListener(this);
  
          pnlControlButtons.add(btnShowAnswer);
          pnlControlButtons.add(btnRight);
          pnlControlButtons.add(btnFalse);
          pnlControlButtons.add(btnEdit);
  
          add(pnlControlButtons, BorderLayout.SOUTH);
      }
  
      private enum Actions {
          SHOW_ANSWER,
          ANSWER_KNOWN,
          ANSWER_UNKNOWN,
  
          CANCEL_MEMORIZATION,
          EDIT_CARD,
      }
  
      public enum Results {
          FINISHED,
          CANCELED,
      }
  
      public static void main(String[] args) {
          JFrame f = new JFrame("test title");
  