4
votes

I am working in a project in which user fills a questionnaire and the answers are then submitted to the server. For simplicity I have just kept two questions per screen and after clicking on the next command the user gets next two questions. I have used lwuit framework in this project.

To reduce the memory requirements I create form, questLabel1, ansCombo1,questLabel2 and ansCombo2 only once. and their properties are set as per the current frame (screen). The problem is if you are in form 2 and you scroll down to the last option and then you click the next button, since you scrolled down the form doesn't displays the upper components even on the next form tried so many thing. creating a new instance of the form may work but I don't want to use that, for obvious memory reasons,

Any other solution?

thanks in advance,

3
the form doesn't displays the upper components even on the next form could you please explain the problem in more details? Are you by chance looking for functionality like one provided by Display.setCurrentItem? "Requests that the Displayable that contains this Item be made current, scrolls the Displayable so that this Item is visible, and possibly assigns the focus to this Item...." - gnat
@gnat: he need to do with LWUIT, not in Java ME. - bharath
thanks @gnat... but the solution u suggested is of lcdui framework, I am using lwuit and only allowed to use lwuit features.... I read the documentation of Display class of lcdui and I just need a similar method for my task... - Amit
understood. Did you check Component/Container API? javadocs I've seen at lwuit page suggest some methods with similar semantics scrollComponentToVisible, scrollRectToVisible. "Makes sure the component is visible in the scroll if this container is scrollable..." stuff like that - gnat
@gnat... thanks alot ... it worked.... thank you very much you saved my day.... God bless u - Amit

3 Answers

3
votes

To make it scroll so that component is visible, check Component/Container API javadocs. I've seen at lwuit page these suggest some methods with semantics that fits - scrollComponentToVisible, scrollRectToVisible. "Makes sure the component is visible in the scroll if this container is scrollable..." stuff like that

  // above extracted from comment to an answer to make it more visible
  // for the case if some reader has similar problem
2
votes

Have you tried form.revalidate()?. Because this is useful when you modify the container hierarchy and need to redo the layout.

Update: Use requestFocus(); on first component of next form. Its automatically focused on first (Upper) component.

1
votes

You can use form.refreshTheme() or form.revalidate() for refreshing your form. If you have made updates on any particular container then do the same for container as well.