Sorry I forget to tell that the list on which I must find the future position of the string is a sorted list, elsewere the problem is inexistent.
I have a sorted searcheable JList with about 200000 sorted words and I must highlight the two word that will surround a new word before it we will be added.
I tried to use the subsequent code:
- Code: Select all
-    protected int searchNearestElement(ListSearchable list,String text) {
 int ret = 0;
 int temp = 0;
 int index = 0;
 list.setCursor(0);
 while(temp >=0 && index < text.length()) {
 temp = list.findNext(text.substring(0, index+1));
 
 if(temp!= -1)
 ret = temp;
 
 index++;
 }
 
 return ret;
 }
But this don't fine in case of a list containing:
 customise
 customize
 customized
 customizing
 customs
when we try to search the word
 
customizzation
because the algorithm find the index of 
customize word instead of the index of 
customizing