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 / December 2007

Tip: Looking for answers? Try searching our database.

Applets and tabs

Thread view: 
Ouabaine - 03 Dec 2007 15:26 GMT
Me again.

About the start() and stop() function of the applet class, and tabs in
nowadays browsers.
Does anyone know if the stop function is called when you quit the current
page by selecting another tab (leaving the page with the applet open)? I
have diverse information from my books. Some books int he stop function they
destroy the applet, in some they do not.
So is the stop method like a pause, or is it a real stop? If it is a pause,
is the start method called when you reenter the page?

Thanks!
Daniel Pitts - 03 Dec 2007 15:39 GMT
> Me again.
>
[quoted text clipped - 8 lines]
>
> Thanks!

You might try an experiment. Those are the best way to learn :-)

Write an applet that keeps track of all the start/stop/init/etc...
The Applet itself could contains a JTextPane which has the results
(append a timestamp and the word "stop" when stop is called, etc...)

I'd be interested in what you find out.
Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

Ouabaine - 03 Dec 2007 18:14 GMT
>> About the start() and stop() function of the applet class, and tabs in
>> nowadays browsers.
>> Does anyone know if the stop function is called when you quit the current
>> page by selecting another tab (leaving the page with the applet open)? I
> You might try an experiment. Those are the best way to learn :-)

Well, this is what I have done, and so far the result is not satisfactory.
The start and stop methods are NOT called when you change the tabs in the
browser! Obviously, the programmers of the applets class did not expect the
browsers to have tabs.
I am sure that the stop/start methods are not called : I have put a null
pointer call in the stop() method of my application, and it does not crash.

I must say I am disapointed, I excpected better. So my games keep on working
(and the music and sounds keep on playing) when you change tabs in the
browsers. Too bad!

Francois
Qu0ll - 03 Dec 2007 20:15 GMT
> Well, this is what I have done, and so far the result is not satisfactory.
> The start and stop methods are NOT called when you change the tabs in the
[quoted text clipped - 7 lines]
> working (and the music and sounds keep on playing) when you change tabs in
> the browsers. Too bad!

Just a thought... have you tried playing with the applet.isVisible() method?
Maybe it will return false when the user goes to another tab in the browser.
If so, you could start a thread that checks it every 20 seconds or so and
takes the appropriate action.

Signature

And loving it,

-Q
_________________________________________________
Qu0llSixFour@gmail.com
(Replace the "SixFour" with numbers to email me)

Joe Attardi - 03 Dec 2007 20:35 GMT
> The start and stop methods are NOT called when you change the tabs in the
> browser! Obviously, the programmers of the applets class did not expect the
> browsers to have tabs.

I don't know. I could be wrong, but IMHO this is the correct behavior.
Switching to a different tab does not close the page being displayed.
Other embedded objects behave in the same way. Go to YouTube and start
playing a video that has sound. Switch to another tab, and notice that
the video keeps on playing.

For more details, check out the description of Applet.stop from the Java
SE 6 API documentation (emphasis mine):

"Called by the browser or applet viewer to inform this applet that it
should stop its execution. It is called ***when the Web page that
contains this applet has been replaced by another page***, and also just
before the applet is to be destroyed."

When you change to a different tab, the Web page containing the applet
has not been replaced by another page. Nor is the page closed (and its
contents destroyed).
Tim Smith - 04 Dec 2007 01:23 GMT
> Well, this is what I have done, and so far the result is not satisfactory.
> The start and stop methods are NOT called when you change the tabs in the
> browser! Obviously, the programmers of the applets class did not expect the
> browsers to have tabs.

You should probably also test with different browsers.  Applets are an
area where it is Write Once Debug Everwhere. :-)
Andrew Thompson - 04 Dec 2007 01:35 GMT
>> Well, this is what I have done, and so far the result is not satisfactory.
>> The start and stop methods are NOT called when you change the tabs in the
>> browser! Obviously, the programmers of the applets class did not expect the
>> browsers to have tabs.
>
>You should probably also test with different browsers.  ...

Ideed.  I whince whenever I see someone mention 'the browser'
when it comes to applet problems.  There is no such thing.
Every browser has its quirks, and each one has different quirks,
and different quirks in different versions.

>...Applets are an
>area where it is Write Once Debug Everwhere. :-)

Yeah.. that's what I keep telling them, but it's good to
hear somebody else say it - maybe it'll finally sink in.  ;-)

Signature

Andrew Thompson
http://www.physci.org/



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



©2009 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.