Skip to main content

timerTask & Label

4 replies [Last post]
heziflash
Offline
Joined: 2008-06-03

Hi
I have 2 questions:
1. I have a timer task that is executing every 1 second and has to show me a variable. What can I do to force the application to show me the variable on the same place and not to increment a line every 1 second?
2. I want the variable increment every time I press the fire button. How can I do it (with Label)?
Thanks
Hezi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
heziflash
Offline
Joined: 2008-06-03

Thanks. I build and run and it works ok.

heziflash
Offline
Joined: 2008-06-03

Hi Shai

I tryed to run the application with
button.getStyle().setBorder(null);
button.getStyle().setBgTransparency(0);

, but it crashed with the following msg:
ALERT: java/lang/NoSuchMethodError: No such method setBorder.(Lcom/sun/lwuit/plaf/Border;)V.
Im using the LWUIT_20080714 jar file.

Thanks
Hezi

Shai Almog

Hi,
> , but it crashed with the following msg:
> ALERT: java/lang/NoSuchMethodError: No such method setBorder.(Lcom/
> sun/lwuit/plaf/Border;)V.
> Im using the LWUIT_20080714 jar file.

This will occur because you compile & link with different versions of
LWUIT... Please check your build environment.

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

[att1.html]

Shai Almog

Hi,
> Hi
> I have 2 questions:
> 1. I have a timer task that is executing every 1 second and has to
> show me a variable. What can I do to force the application to show
> me the variable on the same place and not to increment a line every
> 1 second?

Assuming you have a label on the screen just invoke label.setText(var);

> 2. I want the variable increment every time I press the fire
> button. How can I do it (with Label)?

First you can make a button look like a label (which is better) just
invoke:
button.getStyle().setBorder(null);
button.getStyle().setBgTransparency(0);

Or for older versions:
button.setBorderPainted(false);
button.getStyle().setBgTransparency(0);

That is a better approach.

The second approach is to derive button and override:
protected void keyReleased(int code) {
if(code == Display.GAME_FIRE) {
....
}
}

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

[att1.html]