Skip to main content

append strings

4 replies [Last post]
jit_vogel
Offline
Joined: 2008-06-27
Points: 0

hi, guys

thanks in advance!

in J2ME we can sure use Form.append(String) to show the current string in the mobile screen (refresh the screen). Now i want to know, how can i realize this method using LWUIT?
is it possible in such as TextArea or Container or ...?

Now i can just use:

Form f = new Form("");
TextArea ta = new TextArea(null, 5, 10);
ta.setText("haha");
f.addComponent(ta);
f.show();
try {
Thread.sleep(3000);
} catch(){}
ta.setText("haha hehe")
f.show();

Reply viewing options

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

Hi,
this is automatic for LWUIT. Your Thread.sleep(3000) call would not
work in MIDP either since its blocking the event dispatch thread from
refreshing the screen.
Try this from a separate thread or a timer, there are several
discussions in this forum about the EDT (Event Dispatch Thread) and
quite a bit about it in the developer guide.

Thanks,
Shai.

> hi, guys
>
> thanks in advance!
>
> in J2ME we can sure use Form.append(String) to show the current
> string in the mobile screen (refresh the screen). Now i want to
> know, how can i realize this method using LWUIT?
> is it possible in such as TextArea or Container or ...?
>
> Now i can just use:
>
> Form f = new Form("");
> TextArea ta = new TextArea(null, 5, 10);
> ta.setText("haha");
> f.addComponent(ta);
> f.show();
> try {
> Thread.sleep(3000);
> } catch(){}
> ta.setText("haha hehe")
> f.show();
> [Message sent by forum member 'jit_vogel' (jit_vogel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287201
>
> ---------------------------------------------------------------------
> 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]

jit_vogel
Offline
Joined: 2008-06-27
Points: 0

thanks for the reply.

yes, i found the solution from this forum using:

Display.getInstance().callSerially(new Runnable() {
public void run() {
ta.setText("hahah"+ta.getText());
}
});

But when i use these code in my form, there is an exception:

java.lang.IllegalStateException: Call serially must never be invoked from the EDT

Francis De Brabandere

try this

Form f = new Form("");
final TextArea ta = new TextArea(null, 5, 10);
ta.setText("haha");
f.addComponent(ta);
f.show();
new Thread() {
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Display.getInstance().callSeriallyAndWait(new Runnable() {
public void run() {
ta.setText("haha hehe");
}
});
}
}.start();

On Thu, Jul 17, 2008 at 11:30 AM, wrote:
> thanks for the reply.
>
> yes, i found the solution from this forum using:
>
> Display.getInstance().callSerially(new Runnable() {
> public void run() {
> ta.setText("hahah"+ta.getText());
> }
> });
>
> But when i use these code in my form, there is an exception:
>
> java.lang.IllegalStateException: Call serially must never be invoked from the EDT
> [Message sent by forum member 'jit_vogel' (jit_vogel)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287254
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

--
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

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

jit_vogel
Offline
Joined: 2008-06-27
Points: 0

it runs well!

thanks!!!