J2ME background image

Discussion in 'Java' started by tiff.shaw@gmail.com, Jul 28, 2005.

  1. Guest

    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
    , Jul 28, 2005
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > 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
    --
    jb

    (reply address in rot13, unscramble first)
    Jakob Bieling, Jul 28, 2005
    #2
    1. Advertising

  3. Guest

    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
    , Jul 28, 2005
    #3
  4. <> wrote in message
    news:...

    > 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
    --
    jb

    (reply address in rot13, unscramble first)
    Jakob Bieling, Jul 28, 2005
    #4
  5. Chris Smith Guest

    <> wrote:
    > 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
    Chris Smith, Jul 28, 2005
    #5
  6. Chris Smith Guest

    Jakob Bieling <> wrote:
    > 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
    Chris Smith, Jul 28, 2005
    #6
  7. wrote:
    > 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.


    --
    Darryl L. Pierce <>
    Visit my homepage: http://mcpierce.multiply.com
    "By doubting we come to inquiry, through inquiry truth." - Peter Abelard
    Darryl Pierce, Jul 30, 2005
    #7
  8. mramin05

    Joined:
    Nov 8, 2008
    Messages:
    1
    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
    mramin05, Nov 8, 2008
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. robin
    Replies:
    0
    Views:
    863
    robin
    Jul 20, 2003
  2. Boldra
    Replies:
    0
    Views:
    1,284
    Boldra
    Dec 3, 2003
  3. jc
    Replies:
    3
    Views:
    1,728
  4. jc
    Replies:
    1
    Views:
    1,367
    Neredbojias
    Mar 19, 2008
  5. Dj Frenzy
    Replies:
    3
    Views:
    307
    Robert
    Feb 10, 2004
Loading...

Share This Page