Skip to main content

Autocomplete TextField - repaint issue

4 replies [Last post]
Joined: 2010-02-20

Hi all,

I'm using an autocomplete TextField, as detailed by the example in the LWUITblog (

It's almost working, but in some conditions I am having repaint issues, and wondered if any of you LWUIT gurus had any insights?

I have made a simple AVI using CamStudio to demonstrate the issue: (only 300K, not too huge)

I have made a very simple self-contained midlet that reproduces the problem. Pretty printed source code is here:

Description of problem:

It's a form containing a ComboBox, a label, and then an autocomplete text field.
To see the problem:

1) scroll down to the autocomplete textfield (2nd field down)
2) hit the emulator's '5' key to enter the J character
3) scroll right down to the bottom of the list that has appeared below the textfield
4) scroll right back up to the autocomplete textfield
5) press the emulator's '2' key (corresponds to letter 'a')

At this point the painting goes a little wrong: the textfield doesn't show "Ja", but still just "J". Also, the list below the textfield is mispainted - there are two items visible numbered "1.".

I have some inkling of what is wrong: it's something to do with the scrollbar for the list below the textfield disappearing, but the layout not recalculating properly (hence maybe the clip rect for redrawing being in the wrong place?) However, I'm still not sure how to fix this problem.

Btw, if I don't have a combo box above the autocomplete textfield, the problem goes away. But it would be very useful for my form to have that combobox too.


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2010-02-20

OP here. I appear to have found a solution.
It just involves adding a call to revalidate() when the data has changed:

searchField.addDataChangeListener(new DataChangedListener() {
public void dataChanged(int type, int index) {
form.revalidate(); // NEW CODE **********

(Note: It's revalidate, not invalidate!)

Joined: 2010-02-20


in case anyone wants to run the code, here's a copy of the source *without* the line numbers included:

Joined: 2010-02-20

P.P.S. although any LWUIT theme file would probably do, here's a copy of the simple theme file that the source code above loads.

Joined: 2003-11-07

I think this is related to a relatively new change Ofir did to the text field:
protected void deinitialize() {

Try to remove the line deregisterAnimated(this) from and see if it solves the issue. If it does then please file a bug in the issue tracker.