I put in system print outs to see where the problem was, and 2 and 7 were the two that kept repeating in the infinite loop. This part of the code is suppose to search a list and find the match that the user puts in, but every time i use the search the GUI freezes or is stuck in an infinite loop. Can anyone help me fix this ?
Here is the code i have:
if (whichOne.equals("Search"))
{
System.out.println("1");
String[] results = new String [5];
int count = 1;
list.moveCursorToRear();
int last = list.cursor;
list.resetCursor();
while(list.hasNext() || list.cursor == last)
{
int found = list.search(searchField.getText());
String result = list.spaces[found].getData();
System.out.println("2");
if(current != found)
{
list.stepCursorBack();
System.out.println("3");
if(list.cursor == list.head)
{
results[count] = result;
System.out.println(results[count]);
list.spaces[current].setLink(list.spaces[found].getLink());
count++;
System.out.println("4");
}
else
{
results[count] = result;
System.out.println(results[count]);
list.spaces[current].setLink(list.spaces[list.cursor].getLink());
count++;
System.out.println("5");
}
list.getNext();
System.out.println("6");
}
else
{
//break;
//System.exit(0);
list.hasNext();
System.out.println("7");
}
}