Yishai
Yishai

Reputation: 91931

How to turn off key handling on BasicTreeUI

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?

Upvotes: 0

Views: 363

Answers (2)

camickr
camickr

Reputation: 324197

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();
    }
};

Upvotes: 0

PH.
PH.

Reputation: 388

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

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

Upvotes: 1

Related Questions