Currently I have a program that generates a tree. I used https://stackoverflow.com/a/8948691 to get a string output of the tree. For this, I slightly altered the function in the link: Instead of using System.out.println I rewrote the code to fit my requirements:
public String getStringRepresentation(String prefix, boolean end, int position)
    {
        String retval = prefix + (position != -1? (end ? "└──" : "├──") + " " + position  +(branches==null? "[" + content + "]" : ""):"") + "\r\n";
        if(branches != null)    
        {
            for (int i = 0; i < branches.size() - 1; i++) {
                retval += branches.get(i).getStringRepresentation(prefix + (end ? "    " : "│   "), false,i);
            }
            if (branches.size() >= 1) {
                 retval += branches.get(branches.size() - 1).getStringRepresentation(prefix + (end ?"    " : "│   "), true,branches.size() - 1);
            }
        }
        return retval;   
    }
An example text output would be
├── 0
│   ├── 0[F]
│   └── 1
│       ├── 0[V]
│       └── 1[A]
└── 1
    ├── 0[D]
    └── 1[S]
This String I display with the following:
JTextArea textarea = new JTextArea(infoMessage);
        textarea.setFont(new Font("monospaced", Font.PLAIN, 14));
        JOptionPane.showMessageDialog(null, textarea);
which looks like this:

(As you can see, the alignment is not as it should be.)
                        
I found the problem. Apparently monospaced is not the right font. If I use "consolas" (the one my notepad uses), everything is displayed correctly.