I am writing a simple lookup window. It has a table with two columns(column 1 is abbreviations, and column 2 is the description). The window provides this incremental search kind of capability(as you type in the search JTextField, it highlights and scroll to the closest match on the table). The problem I have is this: I managed to get it to highlight and scroll to show the match item on the table BUT what I would like to be able to do is to ALWAYS have the highlighted/matched item to be on top of the table.
Example: Table has 5 rows (a,b,c,d,e) but only two rows are visible(a &b)
When I typed in d, it scrolls down two rows and shows c and d
What I really want is for it to scroll far enough to ensure that d would be the topmost visible row on the table(show d and e instead of c and d).
I want this same effect regardless it's scrolling up or down.
Here's the code snippet that does the highlighting and scrolling (but highlighted item does not go to top of table)
Rectangle rect = lookupTable.getCellRect(i,0,true);
Any help is greatly appreciated,