开发者

GUI update issue in J2ME

开发者 https://www.devze.com 2023-01-17 00:06 出处:网络
Let\'s say I have two forms: form1 and form2. After pressing a NEXT_COMMAND in form1, I need to change the value of the gauge in form2 and then show form2. Thus:

Let's say I have two forms: form1 and form2.

After pressing a NEXT_COMMAND in form1, I need to change the value of the gauge in form2 and then show form2. Thus:

public void commandAction(Command command, Displayable displayable) {
....
else if (displayable == form1) {
    if (command == NEXT_COMMAND) {
        form2_gauge.setValue(value);
        display.setCurrent(form2);
    }
....
}
....

However, this doesn't work as I expected it to. It doesn't change a thing at first. On the other hand, if I go开发者_StackOverflow中文版 back from form2 to form1 and then again from form1 to form2 it would work.

I can't figure it out myself. I'd be enormously grateful of any possible help.

Thanks!


It seems to me that form2.gauge isn't correct here. You have to save the Gauge object like this:

Gauge form2_gauge([...]);
form2.append(form2_gauge);

Then your code would be:

[...]
    form2_gauge.setValue(value);
    display.setCurrent(form2);
[...]

Have you tried another sequence? Like this:
display.setCurrent(form2);
form2_gauge.setValue(value);
I don't think it would change anything, but may make it work.

0

精彩评论

暂无评论...
验证码 换一张
取 消