• Post Reply Bookmark Topic Watch Topic
  • New Topic

Find many token  RSS feed

 
Gizzmo Zeuzere
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
In a jtextarea, i must find the word "public"
This code works only once but i don't how to cover all the jtextarea:
int index=-1;
int finIndex;
String fin="";
index=agl.document.getText().indexOf("public");
while(index!=-1)
{
for(finIndex=index+1;fin.hashCode()!=KeyEvent.VK_ENTER;finIndex++)
{
agl.document.setSelectionStart(finIndex-1);
agl.document.setSelectionEnd(finIndex);
agl.document.select(agl.document.getSelectionStart(),agl.document.getSelectionEnd());
fin=agl.document.getSelectedText();
}
agl.document.setSelectionStart(index);
agl.document.setSelectionEnd(finIndex);
agl.document.select(agl.document.getSelectionStart(),agl.document.getSelectionEnd()-2);

index=-1;
index=agl.document.getText().indexOf(statut);
/*document is my jtextarea
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!