views:

92

answers:

1

I have a JList inside a Scrollpane. If you click on the list and move the arrow keys up and down it works like you expect, you can move your selection index and display around just fine.

Now, what I want to do is basically have a text box and i'm typing in the text box like "comic" and want it to seek to the index of that value. This WORKS just fine.

Where the problem is when the value of the list box is below, or above the viewable area. When it is, the selected index seeks, but does not change the position of the scrollable region. However, if I press the up or down arrows and requestFocus() to the list, and move up and down it seeks to the right viewable area.

What am I missing to make this happen WITHOUT changing focus. I want to be able to just type in the list all I want and have it show me what is selected. I feel i'm missing something obvious here.

+4  A: 

If I understand the question then you should be able to use:

list.setSelectedIndex(...);
list.ensureIndexIsVisible(...);

If that doesn't help then post your SSCCE demonstrating the problem.

camickr
This worked perfectly, just what I was missing. I looked through that API page no less than 10 times and I'm not sure how I missed that method. Thanks again!
Mech Software