In another post, Shai explained a trick to allow a complete word to be written before launching the reading into the Database. I modified it a bit to allow one or several words to be written and the reading to be launched when I found a blank space.
I have 4 forms which apply the same principle but only 2 works perfectly, the other 2 do not show the list after the blank. To get the list displayed, I have to click anywhere in the form and click again on the autocompletetextfield.
Carefully review all routines and they are almost identical. I'm baffled and I need support to solve this silly situation (my code below).
The following image shows the form that works perfectly by launching the list after the blank space.
The following images show another form that does not work after the blank space and a second image where you click on another point of the form and then on the component.
Container cnArticulos = new Container(BoxLayout.y());
cnArticulos.setScrollableY(true);
DefaultListModel lmArticulos = new DefaultListModel();
AutoCompleteTextField acNombreArticulo = new AutoCompleteTextField(lmArticulos) {
@Override
protected boolean filter(String text) {
if (text.length() == 0) {
return false;
}
char[] p = text.toCharArray();
if (p.length == 0) {
return false;
} else if (p[p.length - 1] != ' ') {
return false;
}
}
ArrayList l = dT.leeInformacionRegistro(text, ARTICULO_LEE_NOMBRE_REGISTRO);
if (l == null || l.isEmpty()) {
return false;
}
if (l.size() < LIMITE_DATOS) {
Vector vArticulos = new Vector();
lmArticulos.removeAll();
for (int i = 0; i < l.size(); i++) {
Articulo aRt = registroArticulo((Map<String, String>) l.get(i));
lmArticulos.addItem(aRt.getNombre());
vArticulos.addElement(aRt);
}
data.setArticulos(vArticulos);
Vector vArticuloEvaluacion = new Vector();
l = dT.leeInformacionRegistro(text, ARTICULO_EVALUACION_LEE_FILTRO_ARTICULO);
if (l != null) {
for (int i = 0; i < l.size(); i++) {
ArticuloEvaluacion aEv = registroArticuloEvaluacion((Map<String, String>) l.get(i));
vArticuloEvaluacion.addElement(aEv);
}
}
data.getArticuloEvaluacion();
} else {
Dialog.show(idioma.getInformacion(), idioma.getMensaje21(), idioma.getContinuar(), null);
}
return true;
}
};