J2ME background image

T

tiff.shaw

Hi,

I'm trying to create a small J2ME app which displays some text on top
of a background image.

The text part is easy - I use a form and some StringItems ... but when
I add an image using
form.append(image)
then the image gets put underneath the previous item.

Is there a simple way to just set a background image? (surely it must
be a common thing?)

-=-=-
I also wanted to show a progress bar but when I do
setCurrent(gauge);
getSomeDataRemotely();
setCurrent(form);
then the progress bar never gets displayed ... but if I comment out
setCurrent(form);
then it does get displayed!!! This seems illogical!

Thanks in advance

Chris
 
J

Jakob Bieling

Hi,

I'm trying to create a small J2ME app which displays some text on top
of a background image.

The text part is easy - I use a form and some StringItems ... but when
I add an image using
form.append(image)
then the image gets put underneath the previous item.

Is there a simple way to just set a background image? (surely it must
be a common thing?)

This is not possible using Forms.
-=-=-
I also wanted to show a progress bar but when I do
setCurrent(gauge);
getSomeDataRemotely();
setCurrent(form);
then the progress bar never gets displayed ... but if I comment out
setCurrent(form);
then it does get displayed!!! This seems illogical!

Depends on how long getSomeDataRemotely() needs. If it completes in
an instant, you might not see the 'gauge' Displayable. If it takes time
to complete, the request might be delayed and will not be processed,
because you are constantly doing stuff. From the docs for setCurrent:

"Requests that a different Displayable object be made visible on the
display. The change will typically not take effect immediately. It may
be delayed so that it occurs between event delivery method calls,
although it is not guaranteed to occur before the next event delivery
method is called. The setCurrent() method returns immediately, without
waiting for the change to take place."

hth
 
T

tiff.shaw

Thanks for replying

Is there a better option available to display, say, 4/5 rows of textual
data on top of a background image?
I guess I could use a Canvas and drawString at a co-ordinate but that
sounds messy.

... for the gauage, yes it takes some time to return ... which is why I
wanted a progress bar ... is there any way to force a refresh? Or is
there another approach? Surely a progress gauage was designed for such
scenarios?

thanks

Chris
 
J

Jakob Bieling

Is there a better option available to display, say, 4/5 rows of
textual
data on top of a background image?
I guess I could use a Canvas and drawString at a co-ordinate but that
sounds messy.

I guess the canvas is the only option, if you must have the
background image. But it probably is not as messy as you might think.

An alert would also work, but this is not quite what you want. But
it lets you display a little bit of text with an image (I think the
image will be above the text .. not sure tho).
.. for the gauage, yes it takes some time to return ... which is why I
wanted a progress bar ... is there any way to force a refresh? Or is
there another approach? Surely a progress gauage was designed for such
scenarios?

Yes, but I have never used progress bars .. A wild guess would be to
call Thread.yield (); or maybe Thread.sleep (10); to give control to the
JVM .. maybe then it will display the progress bar thing. Worth a try.

hth
 
C

Chris Smith

Is there a better option available to display, say, 4/5 rows of textual
data on top of a background image?
I guess I could use a Canvas and drawString at a co-ordinate but that
sounds messy.

First you should convince yourself that you really need a background
image. If you do, then Canvas is the way to go.
.. for the gauage, yes it takes some time to return ... which is why I
wanted a progress bar ... is there any way to force a refresh? Or is
there another approach? Surely a progress gauage was designed for such
scenarios?

Yes, the progress bar is designed for such scenarios... but you can't do
them in the thread that's used to call event handlers. J2ME doesn't
actually guarantee that this will break, unlike J2SE's AWT which is
quite explicit about the matter. Still, it doesn't guarantee that this
will work either. Instead, you should try starting a new Thread to do
the long work and update the Gauge occasionally.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Chris Smith

Jakob Bieling said:
Yes, but I have never used progress bars .. A wild guess would be to
call Thread.yield (); or maybe Thread.sleep (10); to give control to the
JVM .. maybe then it will display the progress bar thing. Worth a try.

Actually, it's not. An important thing to remember in J2ME is that
implementations are given a lot more flexibility than in J2SE. Unless
your goal is for your application to only work on one specific phone,
it's NOT good enough to program by trial and error. It is necessary to
understand the specification and its guarantees and contracts, so that
you avoid the pitfalls of writing code that works fine in the emulator
or in your specific mobile device that you're using for testing, but
doesn't work anywhere else.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
D

Darryl Pierce

Hi,

I'm trying to create a small J2ME app which displays some text on top
of a background image.

The text part is easy - I use a form and some StringItems ... but when
I add an image using
form.append(image)
then the image gets put underneath the previous item.

That's because it's a part of the Form and not the background for the
form. There's no way to set a background for a Displayable item.
 
Joined
Nov 8, 2008
Messages
1
Reaction score
0
Add an image button on canvas

Hi,
I want to add an image button on canvas. I have added an image as a background and then want to add a button on the background.
By pressing the buttion I want to do some task.
How can I do that? any Idea? If someone show me and code example then it will be better for me.
Waiting.

Amin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top