Listbox Scroll To

Looking for the way to make a listbox scroll to what is selected. (It really should be doing this by default.)

If you are using your arrow keys within the lisbox, the scroll bars move to show what is selected. But if you use a button to set the selected Value or Index, it does not scroll up or down to show it. It selects the item, but if it’s off the viewable area, you don’t get to see it.

I’ve used some scrolling code for the power table before that works well:
from java.awt import Rectangle
table = event.source.parent.getComponent(‘MainTable’).getTable()
viewport = table.getParent()
rect = viewport.getViewRect()
newRect = Rectangle(rect.x, rect.y + 288, rect.width, rect.height)

But I need to use a Listbox for this.


if event.propertyName == "selectedIndex": jl = event.source.getComponent(0).getComponent(0) jl.ensureIndexIsVisible(event.newValue)

Put this in the propertyChange event of the listbox

Worked like a champ! Exactly what I needed. Thanks!
Where would I find those commands?