Skip to main content

Scrolling on a growing container

3 replies [Last post]
Anonymous

Hi,

Sorry if this has been commented before.
It was easy to get scrolling working on a statical list of Labels placed
on the Y_AXIS of a Container. However, when those elements are added
dynamically, say via a command that is activated after the form is
shown, the scrollbar appears and one can focus down the list of elements
but once you get to the last visible element, the focus goes out of
sight and so the container doesn't really scroll down. I found a
workaround, which is to call form.show() again after the new elements
are added (revalidate() and repaint() don't help), and then scrolling
works as it should.

Is there a way of letting the container/form know its size has changed
so that when the focused element is not on screen it will follow?
If explanations are not clear enough I can add sample code.

Thanks in advance!
Arnau

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
this is the issue of List bigger than a scrollable container.
Try placing the list in the center of a border layout form and set
the form to scrollable false (the list is scrollable on its own).

> Hi,
>
> Sorry if this has been commented before.
> It was easy to get scrolling working on a statical list of Labels
> placed on the Y_AXIS of a Container. However, when those elements
> are added dynamically, say via a command that is activated after
> the form is shown, the scrollbar appears and one can focus down the
> list of elements but once you get to the last visible element, the
> focus goes out of sight and so the container doesn't really scroll
> down. I found a workaround, which is to call form.show() again
> after the new elements are added (revalidate() and repaint() don't
> help), and then scrolling works as it should.
>
> Is there a way of letting the container/form know its size has
> changed so that when the focused element is not on screen it will
> follow?
> If explanations are not clear enough I can add sample code.
>
> Thanks in advance!
> Arnau
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

Arnau Vàzquez

Hi Shai, thanks but I did a mistake when explaining. The Labels are not
inside a List LWUIT element, they are independent elements added each
one on the container (which is on the center of a border layout and the
form is set to scrollable false). That changes the issue, right?

En/na Shai Almog ha escrit:
> Hi,
> this is the issue of List bigger than a scrollable container.
> Try placing the list in the center of a border layout form and set the
> form to scrollable false (the list is scrollable on its own).
>
>> Hi,
>>
>> Sorry if this has been commented before.
>> It was easy to get scrolling working on a statical list of Labels
>> placed on the Y_AXIS of a Container. However, when those elements are
>> added dynamically, say via a command that is activated after the form
>> is shown, the scrollbar appears and one can focus down the list of
>> elements but once you get to the last visible element, the focus goes
>> out of sight and so the container doesn't really scroll down. I found
>> a workaround, which is to call form.show() again after the new
>> elements are added (revalidate() and repaint() don't help), and then
>> scrolling works as it should.
>>
>> Is there a way of letting the container/form know its size has
>> changed so that when the focused element is not on screen it will follow?
>> If explanations are not clear enough I can add sample code.
>>
>> Thanks in advance!
>> Arnau
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
>>
>> For additional commands, e-mail: users-help@lwuit.dev.java.net
>>
>>
>
> Shai Almog
> http://lwuit.blogspot.com/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

Shai Almog

Completely, set it to scrollable true...
You will also need focusable elements to select, labels are focusable
false by default.

> Hi Shai, thanks but I did a mistake when explaining. The Labels are
> not inside a List LWUIT element, they are independent elements
> added each one on the container (which is on the center of a border
> layout and the form is set to scrollable false). That changes the
> issue, right?
>
> En/na Shai Almog ha escrit:
>> Hi,
>> this is the issue of List bigger than a scrollable container.
>> Try placing the list in the center of a border layout form and set
>> the form to scrollable false (the list is scrollable on its own).
>>
>>> Hi,
>>>
>>> Sorry if this has been commented before.
>>> It was easy to get scrolling working on a statical list of Labels
>>> placed on the Y_AXIS of a Container. However, when those elements
>>> are added dynamically, say via a command that is activated after
>>> the form is shown, the scrollbar appears and one can focus down
>>> the list of elements but once you get to the last visible
>>> element, the focus goes out of sight and so the container doesn't
>>> really scroll down. I found a workaround, which is to call
>>> form.show() again after the new elements are added (revalidate()
>>> and repaint() don't help), and then scrolling works as it should.
>>>
>>> Is there a way of letting the container/form know its size has
>>> changed so that when the focused element is not on screen it will
>>> follow?
>>> If explanations are not clear enough I can add sample code.
>>>
>>> Thanks in advance!
>>> Arnau
>>>
>>> --------------------------------------------------------------------
>>> -
>>> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
>>>
>>> For additional commands, e-mail: users-help@lwuit.dev.java.net
>>>
>>>
>>
>> Shai Almog
>> http://lwuit.blogspot.com/
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]