GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Highlight multiple nodes in jtree Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Highlight multiple nodes in jtree" Watch "Highlight multiple nodes in jtree" New topic
Author

Highlight multiple nodes in jtree

Swetha Krish
Greenhorn

Joined: Jun 27, 2011
Posts: 6
There is a search box, on entering the text fireDocumentChangeEvent is done to search the jtree and the matched nodes are selected.
Here only one node is selected and also I have a tree listener which downloads data for the selected node.

My need is If I give the string as "flo" then all the nodes that contains char "flo" should be highlighted.


Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4571
    
    5

So which do you have a problem with?
  • Identifying the nodes that contain "flo"?
  • Selecting multiple nodes?


  • luck, db
    There are no new questions, but there may be new answers.
    Rob Spoor
    Sheriff

    Joined: Oct 27, 2005
    Posts: 19697
        
      20

    If selecting multiple nodes is not possible (because you allow only single selection), use a custom TreeCellRenderer to do the highlighting for you.


    SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
    How To Ask Questions How To Answer Questions
    Darryl Burke
    Bartender

    Joined: May 03, 2008
    Posts: 4571
        
        5

    Selecting multiple nodes (TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) is the defaule selectionMode.
     
    GeeCON Prague 2014
     
    subject: Highlight multiple nodes in jtree