开发者

jList in Scrollpane, seeking and displaying value of selectedIndex

开发者 https://www.devze.com 2022-12-24 05:21 出处:网络
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.

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 t开发者_开发技巧o just type in the list all I want and have it show me what is selected. I feel i'm missing something obvious here.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号