We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › pre-loading bar for large java applets
Pages: 1 2 
pre-loading bar for large java applets (Read 2124 times)
pre-loading bar for large java applets
Mar 30th, 2009, 11:18am
 
I have almost finished my webpage but find that the main Java object I have is loading too slow, so I thought a progress bar would be in order. I was told that the following solution could work: http://www.javaworld.com/javaworld/jw-12-1996/jw-12-progressbar.html?page=1

The last conversation on this topic I think was back in 2006, or that's what I found when I did a search, I was therefore wondering if there might have been developments in Processing or somebody else's ideas have proven better.

Following the tutorial on the site (http://www.javaworld.com/javaworld/jw-12-1996/progressbar/ExampleWithProgressBar...)  the first question I have is that the code that Processing gives accounts for IE and non IE browsers and would it be this that gets placed in the "MyApplet.java" and then that code in the HTML replaced with Code:
    <APPLET CODE="MyApplet.class" WIDTH=283 HEIGHT=190></APPLET>
?

My website: http://www.meta.projectmio.com/index3.html

Thanks
Re: pre-loading bar for large java applets
Reply #1 - Mar 30th, 2009, 11:54am
 
yes, appletobject was partially made to do that. the site is currently down but you can grab the files from github:

http://github.com/fjenett/appletobject/

there's a test included in the test directory. you need to export your applet with multiple .jars (see processings preference window).

F
Re: pre-loading bar for large java applets
Reply #2 - Apr 6th, 2009, 7:13am
 
Hello, I have had time to look at the code and have been trying to figure out how it works, I think I understand most of it. But when I try to integrate it with my code I get text at the top of the screen which before was acepted as code, I'm not sure why this is as I copied and pasted the code from the example:

Code:
//' ); } other callbacks to override are: ao.onfail = function ( err ) { ... } ao.oninit = function () { ... } ao.onload = function () { ... } */ // now, all set, start loading! // ao.preload( element_id ); } //]]>   



My website: www.meta.projectmio.com/index3.html


Also, I'm not sure how the get the loader to work automatically instead of having to press the 'run' link, I can see the code but don't know what to change.

It's a great example thanks.
Re: pre-loading bar for large java applets
Reply #3 - Apr 6th, 2009, 7:42am
 
your code is outside of the <script ..> tag. that's why it's showing on the page.

to autostart the loader you can add after the loadApplet function but inside the script tag:

Code:

window.addEventListener( "load", function () {
   loadApplet("element-id-of-the-element-to-load-in");
}, true );


let me know if that works for you ..

F
Re: pre-loading bar for large java applets
Reply #4 - Apr 6th, 2009, 7:51am
 
I think you need a </script> after <script type='text/javascript' src='breakinorout.js'>

Firefox's View Source with its syntax highlighting made this obvious... Smiley
Re: pre-loading bar for large java applets
Reply #5 - Apr 6th, 2009, 8:37am
 
Thanks the code was out and is now in the script tags, its always the simple things. Having modified the code I don't see the progress bar like in the example, I tried clearing my history to try o get it to work from a fresh but nothing.. that always confused me about the example as to how it didn't cache anything and always loaded the files, I suppose it just ran through the script step by step.

Anyway, the percentage bar is not showing up in my mod. I was looking at the params section and thought maybe that was stuck behind the main java (attempt8) window, so the process bar is hidden?

And I'm not sure if I need to define any "Callbacks", really I just need the percentage meter to load the jar files and dissapear when done to show the main applet.

Thanks again guys..
Re: pre-loading bar for large java applets
Reply #6 - Apr 6th, 2009, 1:01pm
 
the progress bar shows how many jars have been loaded, not how many bytes.

appletobject relys upon the java cache. to check if the file was loaded before it will attempt to reload it. that's why you see multiple steps in the example (test) although it was run before. appletobject itself has no cache.

i get a script error because of "breakinout.js" not being found. looks like appletobject is never run then ...

F
Re: pre-loading bar for large java applets
Reply #7 - Apr 6th, 2009, 9:45pm
 
Oh, I see, the code just loads the files anyway - thanks for clearing that up. I didn't notice about "breakinout.js", but the strange thing is that I can't find it! and if I take it out something breaks, so I moved it and the page still works as it should.

But, I've been going over that code and its the same as the example so I'm just not sure why its not showing the percentage bar?? I'm concerned about this section, do I need the 'test_string', especially as none of it shows up and this is what I want to show I think:

Code:
// add some params
//
ao.addParams( ['boxmessage','Loading Processing software...'],
['boxbgcolor','#DDDDCC'], // HTML background color
['progressbar','true'],
['test_string','hurray!'] );
Re: pre-loading bar for large java applets
Reply #8 - Apr 6th, 2009, 11:12pm
 
no, the teststring is to show that custom parameters can be passed to the appletobject.

you need to put the "window.addEventListener ..." inside a script tag but not inside another function. put it next to loadApplet.

inside the "window.addEventListener .." there is a string "element-id-of-the-element-to-load-in" that i pass to the loadApplet function. that string needs to be the id of the div that appletobject loads the applet into. ... i think you don't hav a div for that at the moment, put one in.

you placed the applet code (anything inside <div id="attempt8_container">) into your page, that will just show the applet there and will not use appletobject. you need to have an empty <div id="load_applet_here"></div>. (in this case "load_applet_here" goes into loadApplet() inside "window.addEvent...").

ok?
F
Re: pre-loading bar for large java applets
Reply #9 - Apr 7th, 2009, 9:05am
 
I tried to understand what you said:

"you need to put the "window.addEventListener ..." inside a script tag but not inside another function. put it next to loadApplet."

I put the code then above the "//<![CDATA[" but still inside the script tag, this should then be seen first in the code, is that right?


"inside the "window.addEventListener .." there is a string "element-id-of-the-element-to-load-in" that i pass to the loadApplet function. that string needs to be the id of the div that appletobject loads the applet into... i think you don't hav a div for that at the moment, put one in."

I changed that "element-id-of-the-element-to-load-in" to the closest thing I could find that was the "id of the div that appletobject loads the applet into." which I thought was "element_id" from "function loadApplet ( element_id )" ..but I'm not sure


"you placed the applet code (anything inside <div id="attempt8_container">) into your page, that will just show the applet there and will not use appletobject. you need to have an empty <div id="load_applet_here"></div>. (in this case "load_applet_here" goes into loadApplet() inside "window.addEvent...")."

I put a "<div id="attempt8_container"></div>" inside the code you gave me below, was that right?:

Code:
window.addEventListener( "load", function () {
loadApplet("element_id");
<div id="attempt8_container"></div>
}, true );



..and that's now above the "//<![CDATA[" but still within the script tags. The page loads okay but not the percentage bar, I was looking back at the example and cross-referencing that with what you said but its not that easy, I find.

Thanks again!
Re: pre-loading bar for large java applets
Reply #10 - Apr 7th, 2009, 12:13pm
 
here's what you need to do, step by step:

- fix the script tag pointing to "breakinorout.js" because that file is still missing and causes parse errors (which may prevent any other scripts from being run at all)

- remove the contents (<object>, ..) of this element: <div id="attempt8_container"> .... </div>

- put the CDATA back in the first line of the script tag

- right after that put:

window.addEventListener( "load", function () {
  loadApplet("attempt8_container");
}, true );


reload page, cross fingers .. in case it does not work let me know.

F
Re: pre-loading bar for large java applets
Reply #11 - Apr 7th, 2009, 2:36pm
 
Thanks for bearing with me, I did as you said (I think) and it now, still works, has a gray thing at the top that says "Restore Frame", if I click it it goes to a 404 with the page name tacked on to end of the url, strange.

But I think that the gray window is the percentage window? Just not working properly..
Re: pre-loading bar for large java applets
Reply #12 - Apr 8th, 2009, 6:50am
 
hmm, no you didn't ... Smiley

just copy-paste this over:
Code:

<script type='text/javascript' src='/code/breakinorout.js'></script>
<script type="text/javascript" src="/code/appletobject.js"></script>
</script type="text/javascript">
//<![CDATA[

window.addEventListener( "load", function () {
 loadApplet("attempt8_container");
}, true );

function loadApplet ( element_id )
{
// create and init object
//
var ao = new AppletObject( 'attempt8', // main class to start
['/code/attempt8.jar' , // all jars needed by
'/code/bubble_4.jar' , // the applet
'/code/half_Ocillation_Recursion_v4a.jar' ,
'/code/core.jar'],
'100', '100', // width, height
'0', // java version: 1.4.2_13
'true', // mayscript
'', // codebase
[], // additional params
// tag style to generate
AppletObjects.TAG_OBJECT );

// add some params
//
ao.addParams( ['boxmessage','Loading Processing software...'],
['boxbgcolor','#DDDDCC'], // HTML background color
['progressbar','true'],
['test_string','hurray!'] );

// now, all set, start loading!
//
ao.preload( element_id );
}

//]]>
</script>
<div id="attempt8_container"></div>


F
Re: pre-loading bar for large java applets
Reply #13 - Apr 9th, 2009, 7:27am
 
Sorry, its just not having it. Instead of copying the code strait I looked to see what you had done and changed that, to learn more, and it wouldn't work. So I then copied and pasted over my code and it still didn't work for me.

Looking at the bottom where the  final script is and you placed a "<div id="attempt8_container"></div>" beneath it I tried that without the closing div and even without it because I saw one underneath and that didn't work.

Also that gray box with "Restore Frame" is still there and now with two "//" chars, which I think are there because of the "//<![CDATA[", looking at my code above I have it like "/* <![CDATA[ */", so I tried it with just "<![CDATA[" and the "//" went away but it didn't work.

I can appreciate this not being your code and you probably would have this thing liked by now  Wink

Thanks.
Re: pre-loading bar for large java applets
Reply #14 - Apr 9th, 2009, 12:07pm
 
i'd love to help but if you keep on not doing what i tell you i just can't ...

1) your document has no opening <body> tag. you need to fix your html before you can add the appletobject.

2) remove the second <div id="attempt8_container"> .... </div> including it's contents. appletobject will put/generate the needed code into the first empty container.
Pages: 1 2