Highlighting multiple lines in a list

I’m trying to highlight multiple lines in a list when I open a window. The list has a binding to a SQL query.

In the window’s internalFrameActivated event I create a dataset from a database query, then I loop through all the lines in the list and use addSelectionInterval() to highlight the line if a match is found.

However, I am getting inconsistent results - testing seems to show that the length of the list is varying during the course of the script. When does the list get populated? Is it before, during or after the internalFrameActivated script is run?

You don’t know, it could be before or after. So what you need to do is wrap the selection up into an invokeLater which will happen after all of the bindings take place.

Thanks Travis, that worked perfectly.