So string.append
and string2.append
are StringBuilder
objects I made to load words from a text file faster, my problem is that when I switch from radio button occurrence and alphabetical it just adds to the text area instead of replacing the previous list. Any ideas on how to fix this?
for(SuperString word : ss)
{
count++;
string.append(Integer.toString(count)+ " "+ word+ "\n");
string.toString();
}
if(occurrence.isSelected())
{
textarea.setText("");
textarea.append(" "+filename+" has wordcount: "+words.size()+
"\n-------------------------\n\n");
textarea.append(string.toString());
}
for(SuperString word : ss2)
{
count2++;
string2.append(Integer.toString(count2)+ " "+ word.toString()+ "\n");
}
if(alphabetical.isSelected())
{
textarea.setText("");
textarea.append(string2.toString());
}