Scrollpane中的jList,查找并显示selectedIndex的值
我在滚动窗格中有一个 JList。如果您单击列表并上下移动箭头键,它会像您预期的那样工作,您可以移动选择索引并显示周围就好了。
现在,我想做的基本上是有一个文本框,我在文本框中输入“漫画”之类的内容,并希望它查找该值的索引。这工作得很好。
问题出在列表框的值低于或高于可视区域时。如果是,则选定的索引将进行查找,但不会更改可滚动区域的位置。但是,如果我按向上或向下箭头和 requestFocus() 到列表,然后上下移动,它会寻找正确的可视区域。
我缺少什么才能在不改变焦点的情况下实现这一目标。我希望能够在列表中输入我想要的所有内容并让它显示所选择的内容。我觉得我在这里遗漏了一些明显的东西。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解这个问题,那么您应该能够使用:
如果这没有帮助,那么发布您的 SSCCE 来演示问题。
If I understand the question then you should be able to use:
If that doesn't help then post your SSCCE demonstrating the problem.