Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Search backward from last visible row looking for any visible node whose name starts with prefix

import javax.swing.JTree; import javax.swing.text.Position; import javax.swing.tree.TreePath; public class Main {   public static void main(String[] argv) throws Exception {     JTree tree = new JTree();     int startRow = tree.getRowCount() - 1;     String prefix = "b";     TreePath path = tree.getNextMatch(prefix, startRow, Position.Bias.Backward);     System.out.println(path);   } }