Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

J2ME background image

Thread view: 
tiff.shaw@gmail.com - 28 Jul 2005 12:47 GMT
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
Jakob Bieling - 28 Jul 2005 13:03 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> 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
[quoted text clipped - 4 lines]
>  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
Signature

jb

(reply address in rot13, unscramble first)

tiff.shaw@gmail.com - 28 Jul 2005 13:53 GMT
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
Jakob Bieling - 28 Jul 2005 14:05 GMT
> 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
Signature

jb

(reply address in rot13, unscramble first)

Chris Smith - 28 Jul 2005 17:23 GMT
>     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.

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Chris Smith - 28 Jul 2005 17:21 GMT
> 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.

Signature

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Darryl Pierce - 30 Jul 2005 03:54 GMT
> Hi,
>
[quoted text clipped - 5 lines]
>  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.

Signature

Darryl L. Pierce <mcpierce@gmail.com>
Visit my homepage: http://mcpierce.multiply.com
"By doubting we come to inquiry, through inquiry truth." - Peter Abelard



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.