java – Building an ArrayList with JLink


I’m wondering if it’s possible to put this code inside a Manipulate. I tried just like this and got the results in the message box:
enter image description here

Then when I selected a diferent word from the PopMenu I got this:
enter image description here

Thought the problem was the ...Print(...) instructions so tried to build an arraylist like this but totaly failed, there’s no result…

Needs("JLink`")

Scanner(archivo_String, palabra_String) :=
 JavaBlock@
  Module({entrada, linea, numlinea, contiene, ruta, lista, renglon, 
    nop}, numlinea = 1; linea = ""; contiene = False;
   InstallJava();
   ruta = JavaNew("java.io.File", archivo);
   entrada = JavaNew("java.util.Scanner", ruta);
   lista = JavaNew("java.util.ArrayList");
   (*Print("File: " <> ruta@getName());
   Print("Word:" <> palabra);*)
   While(entrada@hasNext(), linea = entrada@nextLine(); 
    If(JavaNew("java.lang.String", linea)@
      contains(MakeJavaObject@palabra), 
     renglon = 
      JavaNew("java.lang.String", 
       "Line " <> ToString(numlinea ) <> ": " <> ToString(linea));
     contiene = True;
     lista@add(renglon);
     JavaObjectToExpression(lista));
    numlinea++);
   If(! contiene, 
    nop = JavaNew("java.lang.String", 
      ToString(palabra) <> " no se ha encontrado");
    lista@add(nop);
    JavaObjectToExpression(lista)))

Don’t know exactly how to do it, I’d appreciate your help.