tags:

views:

52

answers:

2

BasicTreeUI (in JDK 1.5) handles key events on JTree by navigating to an item on the tree that starts with that letter. What is the most straight forward way to turn that behavior off?

+1  A: 

I think the most straightforward way is to override the createKeyListener method:

tree.setUI(
  new BasicTreeUI(){
   protected KeyListener createKeyListener(){ return null; }
  }
 );
PH
A: 

Don't know much about JTree, but it provides a method you can customize:

JTree tree = new JTree(...)
{
    public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias)
    {
        return getLeadSelectionPath();
    }
};
camickr