String () { StringBuilder sb = new StringBuilder(); TreeUtil.visitVisibleRows(tree, path -> { TreeVisitor.Action action = visitor.visit(path); if (filter.test(path)) { int count = path.getPathCount(); for (int i = 1; i < count; i++) sb.append(' '); Object component = path.getLastPathComponent(); if (!tree.getModel().isLeaf(component)) sb.append(tree.isExpanded(path) ? '-' : '+'); boolean selected = selection && tree.isPathSelected(path); if (selected) sb.append('['); sb.append(converter.apply(TreeUtil.getUserObject(component))); if (selected) sb.append(']'); sb.append('\n'); } return action; }); return sb.toString(); }