package example;
//-*- mode:java; encoding:utf8n; coding:utf-8 -*-
// vim:set fileencoding=utf-8:
//@homepage@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.tree.*;

public class MainPanel extends JPanel{
    public MainPanel() {
        super(new BorderLayout());
        add(makeUI());
        setPreferredSize(new Dimension(320, 240));
    }
    private final JTree tree       = new JTree();
    private final JTextField field = new JTextField("foo");
    private final HighlightTreeCellRenderer renderer = new HighlightTreeCellRenderer();
    public JPanel makeUI() {
        field.getDocument().addDocumentListener(new DocumentListener() {
            @Override public void insertUpdate(DocumentEvent e) {
                fireDocumentChangeEvent();
            }
            @Override public void removeUpdate(DocumentEvent e) {
                fireDocumentChangeEvent();
            }
            @Override public void changedUpdate(DocumentEvent e) {}
        });
        JPanel n = new JPanel(new BorderLayout());
        n.add(field);
        n.setBorder(BorderFactory.createTitledBorder("Highlight Search"));

        tree.setCellRenderer(renderer);
        renderer.q = field.getText();
        fireDocumentChangeEvent();

        JPanel p = new JPanel(new BorderLayout(5, 5));
        p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        p.add(n, BorderLayout.NORTH);
        p.add(new JScrollPane(tree));
        return p;
    }
    private void fireDocumentChangeEvent() {
        String q = field.getText();
        renderer.q = q;
        TreePath root = tree.getPathForRow(0);
        collapseAll(tree, root);
        if(!q.isEmpty()) searchTree(tree, root, q);
        //tree.repaint();
    }
    private static void searchTree(JTree tree, TreePath path, String q) {
        TreeNode node = (TreeNode)path.getLastPathComponent();
        if(node==null) return;
        if(node.toString().startsWith(q)) tree.expandPath(path.getParentPath());
        if(!node.isLeaf() && node.getChildCount()>=0) {
            Enumeration e = node.children();
            while(e.hasMoreElements())
              searchTree(tree, path.pathByAddingChild(e.nextElement()), q);
        }
    }
    private static void collapseAll(JTree tree, TreePath parent) {
        TreeNode node = (TreeNode)parent.getLastPathComponent();
        if(!node.isLeaf() && node.getChildCount()>=0) {
            Enumeration e = node.children();
            while(e.hasMoreElements()) {
                TreeNode n = (TreeNode)e.nextElement();
                TreePath path = parent.pathByAddingChild(n);
                collapseAll(tree, path);
            }
        }
        tree.collapsePath(parent);
    }
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            @Override public void run() {
                createAndShowGUI();
            }
        });
    }
    public static void createAndShowGUI() {
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }catch(Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame("@title@");
        //frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.getContentPane().add(new MainPanel());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}
class HighlightTreeCellRenderer extends DefaultTreeCellRenderer {
    private static final Color rollOverRowColor = new Color(220, 240, 255);
    public String q;
    @Override public void updateUI() {
        setTextSelectionColor(null);
        setTextNonSelectionColor(null);
        setBackgroundSelectionColor(null);
        setBackgroundNonSelectionColor(null);
        super.updateUI();
    }
    @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected,
                                                  boolean expanded, boolean leaf, int row, boolean hasFocus) {
        JComponent c = (JComponent)super.getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, hasFocus);
        //DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
        if(isSelected) {
            c.setOpaque(false);
            c.setForeground(getTextSelectionColor());
            //c.setBackground(Color.BLUE); //getBackgroundSelectionColor());
        }else{
            c.setOpaque(true);
            if(q!=null && !q.isEmpty() && value.toString().startsWith(q)) {
                c.setForeground(getTextNonSelectionColor());
                c.setBackground(rollOverRowColor);
            }else{
                c.setForeground(getTextNonSelectionColor());
                c.setBackground(getBackgroundNonSelectionColor());
            }
        }
        return c;
    }
}

@@ -3574,16 +3574,1342 @@
     %7D%0A%7D%0A
+//*%0Aclass HighlightTreeCellRenderer extends DefaultTreeCellRenderer %7B%0A    private static final Color rollOverRowColor = new Color(220, 240, 255);%0A    public String q;%0A    @Override public void updateUI() %7B%0A        setTextSelectionColor(null);%0A        setTextNonSelectionColor(null);%0A        setBackgroundSelectionColor(null);%0A        setBackgroundNonSelectionColor(null);%0A        super.updateUI();%0A    %7D%0A    boolean rollOver = false;%0A    @Override public Color getBackgroundNonSelectionColor() %7B%0A        if(rollOver) %7B%0A            return rollOverRowColor;%0A        %7Delse%7B%0A            return super.getBackgroundNonSelectionColor();%0A        %7D%0A    %7D%0A    @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected,%0A                                                  boolean expanded, boolean leaf, int row, boolean hasFocus) %7B%0A        JComponent c = (JComponent)super.getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, hasFocus);%0A        if(isSelected) %7B%0A            c.setForeground(getTextSelectionColor());%0A        %7Delse%7B%0A            rollOver = q!=null && !q.isEmpty() && value.toString().startsWith(q);%0A            c.setForeground(getTextNonSelectionColor());%0A            c.setBackground(getBackgroundNonSelectionColor());%0A        %7D%0A        return c;%0A    %7D%0A%7D%0A/*/%0A
 class Hi
@@ -6314,28 +6314,33 @@
 %7D%0A        return c;%0A    %7D%0A%7D%0A
+//*/%0A

Change text only highlight instead of include icon highlight