For Programmers: Free Programming Magazines  


Home > Archive > Java Help > March 2004 > how can I show some text or image during loading the applet









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how can I show some text or image during loading the applet
WL Yang

2004-03-27, 12:30 am

Dears all,

Hi all, so long to post question,
here is a problem now I am facing, my applet ( draw some picture or
map ) really need to load for quite long time, ( cause it need much
calculation ), and I want to tell the user that the page is loading. (
not really need to tell the progress ), what can I do for it? I have
tried to change the cursor icon at the very begining of the init() but
it didnt change as I thought. how can I display some String likes, "
LOADING IMAGE " during the applet loading, I have tried to add it
inside paint(), but this only display on my output picture. hope
somebody can help and give some advice.

tks in advance.
Erwin Moller

2004-03-27, 12:30 am

WL Yang wrote:

> Dears all,
>
> Hi all, so long to post question,
> here is a problem now I am facing, my applet ( draw some picture or
> map ) really need to load for quite long time, ( cause it need much
> calculation ), and I want to tell the user that the page is loading. (
> not really need to tell the progress ), what can I do for it? I have
> tried to change the cursor icon at the very begining of the init() but
> it didnt change as I thought. how can I display some String likes, "
> LOADING IMAGE " during the applet loading, I have tried to add it
> inside paint(), but this only display on my output picture. hope
> somebody can help and give some advice.
>
> tks in advance.


Hi Mr Yang,

If your applet is small and the calculations and/or downloading of extra
images takes a long time, I expect you can make it behave better by
rewriting it a bit.

A few hints:
- make sure you init() routine is not responsible for a load a work.
If it return quickly you can be sure the rest of the applet will behave
better.
- same for start()
- make a thread that loads the images you need.
- make a thread that does all the calculations.

In that way you can define the behaviour of init() start() stop() better
IMHO.


- create some boolean bCalculating.

In paint():
bCalculating == true: always paint 'please wait'

When all your work (downloading of images, calculations, etc) is done, then
switch the boolean to false.

bCalculating == false:
do the stuff this applet is supposed to do.

Hope that helps.
Regards,
Erwin Moller
WL Yang

2004-03-27, 12:30 am

Erwin Moller < since_humans_read_this_I_am_spammed_too_
much@spamyourself.com> wrote in message news:<405f0c44$0$562$e4fe514c@news.xs4all.nl>...
> WL Yang wrote:
>
>
> Hi Mr Yang,
>
> If your applet is small and the calculations and/or downloading of extra
> images takes a long time, I expect you can make it behave better by
> rewriting it a bit.
>
> A few hints:
> - make sure you init() routine is not responsible for a load a work.
> If it return quickly you can be sure the rest of the applet will behave
> better.
> - same for start()
> - make a thread that loads the images you need.
> - make a thread that does all the calculations.
>
> In that way you can define the behaviour of init() start() stop() better
> IMHO.
>
>
> - create some boolean bCalculating.
>
> In paint():
> bCalculating == true: always paint 'please wait'
>
> When all your work (downloading of images, calculations, etc) is done, then
> switch the boolean to false.
>
> bCalculating == false:
> do the stuff this applet is supposed to do.
>
> Hope that helps.
> Regards,
> Erwin Moller


thks Erwin, thks for yr idea.

I tried this, and now still has some problems. Now I declare a thread
to display the loading message, and it works. but the image doesnt
display later on ( the code still stay inside init() ), even I call
repaint(); am I still missing something.

thks a lot

Yang
Erwin Moller

2004-03-27, 12:30 am

WL Yang wrote:

<snip>

>
> thks Erwin, thks for yr idea.
>
> I tried this, and now still has some problems. Now I declare a thread
> to display the loading message, and it works. but the image doesnt
> display later on ( the code still stay inside init() ), even I call
> repaint(); am I still missing something.
>
> thks a lot
>
> Yang


Hi Yang,

(Another 2 of my cents. :P)
The best way to understand what applet are doing is, of course, read about
them in some good tutorial. (I liked Sun's tutorials a lot, they are clear:
check java.sun.com for MANY good tutorials).

And just make a System.out.println("entering init"); for entering and
leaving methods you want to study in the applet.
(I advise you to do it for init, start, stop, paint, and every run() for
each thread you want to launch.)
Then start reloading the applet, leaving the html page and come back, etc.
etc., and check the output.
It takes only a few hours to play around, and your insights will increase.
It is not complicated at all, you just have to see the logic by doing basic
stuff first.
(If you are relatively new to threads, be sure to check sun's tutorial first
too.)

Good luck!

Regards,
Erwin Moller
WL Yang

2004-03-27, 12:30 am

Erwin Moller < since_humans_read_this_I_am_spammed_too_
much@spamyourself.com> wrote in message news:<40614b11$0$573$e4fe514c@news.xs4all.nl>...
> WL Yang wrote:
>
> <snip>
>
>
> Hi Yang,
>
> (Another 2 of my cents. :P)
> The best way to understand what applet are doing is, of course, read about
> them in some good tutorial. (I liked Sun's tutorials a lot, they are clear:
> check java.sun.com for MANY good tutorials).
>
> And just make a System.out.println("entering init"); for entering and
> leaving methods you want to study in the applet.
> (I advise you to do it for init, start, stop, paint, and every run() for
> each thread you want to launch.)
> Then start reloading the applet, leaving the html page and come back, etc.
> etc., and check the output.
> It takes only a few hours to play around, and your insights will increase.
> It is not complicated at all, you just have to see the logic by doing basic
> stuff first.
> (If you are relatively new to threads, be sure to check sun's tutorial first
> too.)
>
> Good luck!
>
> Regards,
> Erwin Moller



thanks heartly, Erwin
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com