DzzD
|
 |
«
Posted
2010-04-12 20:36:56 » |
|
here is the new version V2 of the Applet booter ( that was made related to lastest Java 1.6-u19 sucks plugin release... ) Online demo here : http://demo.dzzd.net/BootV2/Download of boot.jar here : http://demo.dzzd.net/BootV2/boot.jarFull demo download here : http://demo.dzzd.net/BootV2/boot.zipsidenote : I believe that to avoid those scary mixed code popup lot of people will just sign and add full rights to everything... this is why the Oracle Upadate 6u19 is so stupid... HTML sample use below :It load the applet "jar.MyJarApplet" and set "myJarApplet.jar;someOtherJar.jar" to its classpath, the applet should start imediatly as only boot.jar is loaded at start (approx 5KB load). If you request to use signed an unsigned jar than you should simply have to self-sign boot.jar and you should be done, let me know... (NB: for simplicity you may make & keep two version of the boot.jar : unsignedBoot.jar and signedBoot.jar that you will use depending if you request or not signed jar) 1 2 3 4 5 6 7 8 9 10 11 12 13
| <applet archive = "boot.jar" code = "Boot" width = "500" height = "300"> <PARAM NAME="BOOTCLASS" VALUE="jar.MyJarApplet"> <PARAM NAME="BOOTJARS" VALUE="myJarApplet.jar;someOtherJar.jar"> <PARAM NAME="BOOTFGCOLOR" VALUE="000000"> <PARAM NAME="BOOTBGCOLOR" VALUE="ffffff"> <PARAM NAME="BOOTTOSTART" VALUE="TRUE"> <PARAM NAME="boxbgcolor" VALUE="#ffffff"> <PARAM name="java_arguments" value="-Dsun.awt.noerasebackground=true"> </applet> |
source : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
|
import java.awt.*; import java.applet.*; import java.awt.image.*; import java.net.*; import java.security.*; import java.security.cert.*; import java.util.*;
public final class Boot extends Applet implements Runnable,AppletStub { public static final long serialVersionUID = 0x00000001; private volatile int nbStart=0; private volatile Graphics g; private volatile int bgColor; private volatile int fgColor; private volatile Container c; private volatile boolean loaded; private volatile Thread t; private volatile Applet a; private volatile boolean bootToStart=false; private volatile Image bImage; private volatile Graphics bg; private int w() { return this.getSize().width; } private int h() { return this.getSize().height; } private int blend(int color1,int color2, int factor) { int f1=256-factor; return ((((color1&0xFF00FF)*f1 + (color2&0xFF00FF)*factor ) &0xFF00FF00 ) | ( ( (color1&0x00FF00)*f1 + (color2&0x00FF00)*factor ) &0x00FF0000 ) ) >>>8; } private volatile int nb=0; private volatile long lTime; public void run() { try { this.lTime=System.currentTimeMillis(); while(!this.loaded) { Color color=new Color(this.bgColor); this.c.setBackground(color); this.bg.setColor(color); this.bg.fillRect(0,0,w(),h()); int cx=this.w()>>1; int cy=this.h()>>1; for(int n=0;n<360;n++) { int RGB=blend(this.fgColor,this.bgColor,(255*n)/360); this.bg.setColor(new Color(RGB)); double a=(nb-n*0.5)*Math.PI/180.0; double ca=Math.cos(a); double sa=Math.sin(a); int x=cx+(int)(8.0*ca); int y=cy+(int)(8.0*sa); int x2=cx+(int)(12.0*ca); int y2=cy+(int)(12.0*sa); this.bg.drawLine(x,y,x2,y2); } this.g.drawImage(this.bImage,0,0,null); nb+=6; long time=System.currentTimeMillis(); long delta=time-lTime; lTime=time; Thread.sleep(5); Thread.yield(); } } catch(InterruptedException ie) { ie.printStackTrace(); } } public Applet getApplet() { return this.a; } public void paint(Graphics g) { if(this.nbStart++==0) { this.bImage=this.createImage(w(),h()); this.bg=this.bImage.getGraphics(); this.bgColor=0xFFFFFF; this.fgColor=0x000000; try { ((Graphics2D)this.bg).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } catch(Throwable t) { t.printStackTrace(); } String sBgColor=this.getParameter("BOOTBGCOLOR"); if(sBgColor!=null) { try { this.bgColor=Integer.parseInt(sBgColor,16); } catch(Throwable t) { t.printStackTrace(); } } String sFgColor=this.getParameter("BOOTFGCOLOR"); if(sFgColor!=null) { try { this.fgColor=Integer.parseInt(sFgColor,16); } catch(Throwable t) { t.printStackTrace(); } } this.c=this.getParent(); this.g=this.c.getGraphics(); this.c.remove(this); this.loaded=false; this.t=new Thread(this); this.t.start(); String bootToStart=this.getParameter("BOOTTOSTART"); if(bootToStart!=null && bootToStart.equals("TRUE")) this.bootToStart=true; String bootClass=this.getParameter("BOOTCLASS"); Color color=new Color(this.bgColor); this.c.setBackground(color); new AppletLoader(bootClass); } } private String[] split(String str,char ch) { if(str==null) return null; if(str.length()==0) return new String[]{""}; int nb=1; int ofs=str.indexOf(ch); while(ofs!=-1) { nb++; ofs=str.indexOf(ch,ofs+1); } String strings[]=new String[nb]; int numString=0; int startIndex=-1; for(int n=0;n<nb;n++) { int endIndex=str.indexOf(ch,startIndex+1); if(endIndex==-1) endIndex=str.length(); strings[n]=str.substring(startIndex+1,endIndex); startIndex=endIndex; } return strings; } URLClassLoader ucl; private class AppletLoader implements Runnable { String name; AppletLoader(String name) { this.name=name; Thread t=new Thread(this,"DZZD APPLET BOOT"); t.start(); } public void run() { try { Thread.sleep(100); String bootArchive=Boot.this.getParameter("BOOTJARS"); String bootArchives[]=Boot.this.split(bootArchive,';'); URL urlJars[]=new URL[bootArchives.length+1]; urlJars[0]=Boot.this.getCodeBase(); for(int n=0;n<bootArchives.length;n++) { URL u=new URL("jar:" + Boot.this.getCodeBase() + bootArchives[n] + "!/"); urlJars[n+1]=u; System.out.println ("Adding JAR " + u); } URLClassLoader ucl=null; try { ucl=new BootClassLoader(urlJars); } catch(Throwable t) { ucl=((URLClassLoader) Thread.currentThread().getContextClassLoader()).newInstance(urlJars); } Boot.this.a=(Applet)ucl.loadClass(this.name).newInstance(); Boot.this.a.setVisible(false); { Boot.this.a.setStub(Boot.this); Boot.this.c.add(Boot.this.a); Boot.this.a.resize(new Dimension(Boot.this.w(),Boot.this.h())); Boot.this.a.init(); if(!Boot.this.bootToStart) Boot.this.a.setVisible(true); Boot.this.a.start(); if(Boot.this.bootToStart) Boot.this.a.setVisible(true); } Boot.this.loaded=true; Boot.this.t.join(); } catch(Throwable e) { e.printStackTrace(); } } } public void start() { if(this.a!=null) this.a.start(); } public void stop() { if(this.a!=null) this.a.stop(); } public void destroy() { if(this.a!=null) this.a.destroy(); this.a=null; } public void appletResize(int width, int height) { if(this.a!=null) this.a.setSize(width,height); } }
|
|
|
|
|
broumbroum
|
 |
«
Reply #1 - Posted
2010-04-12 21:45:43 » |
|
WOW ! nice loader !  Is there any way to load native libraries ? I mean, the goal of a good applet loader is to make native stuff like a openGL context available... otherwise a loader deserves no real price to the usual applet. 
|
|
|
|
DzzD
|
 |
«
Reply #2 - Posted
2010-04-12 21:55:50 » |
|
WOW ! nice loader !  Is there any way to load native libraries ? yes inded, not tested but if the boot.jar is signed you will benefit from its classloader rights and should be able to download the native dll/so/others... and load them at runtime with System.load( ... ) also not yet implmented but by sliglty modifying the boot class it is possible to make jar loading whenever you need it (by implemeting a loadJar method) , for now all jar are loaded after the boot Applet start and before the sub-applet is launched. EDIT : if you got a Java version under 1.6-u19 you can see native lib loading at runtime here http://demo.dzzd.net/FPSSample9/ when hitting H key natives libraries (dll, so or other) are downloaded and loaded in memory from the remote applet server to use opengl via JOGL.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
DzzD
|
 |
«
Reply #3 - Posted
2010-04-12 22:11:56 » |
|
I have updated the HTML to make load a little better : added some new plugin stuff 1 2 3 4 5 6 7 8 9 10 11 12
| <applet archive = "boot.jar" code = "Boot" width = "500" height = "300"> <PARAM NAME="BOOTCLASS" VALUE="jar.MyJarApplet"> <PARAM NAME="BOOTJARS" VALUE="myJarApplet.jar;someOtherJar.jar"> <PARAM NAME="BOOTBGCOLOR" VALUE="000000"> <PARAM NAME="BOOTTOSTART" VALUE="TRUE"> <PARAM NAME="boxbgcolor" VALUE="#000000"> <PARAM name="java_arguments" value="-Dsun.awt.noerasebackground=true"> </applet> |
|
|
|
|
DzzD
|
 |
«
Reply #4 - Posted
2010-04-12 22:30:04 » |
|
I mean, the goal of a good applet loader is to make native stuff like a openGL context available... otherwise a loader deserves no real price to the usual applet.  not really, I think you missed some others importants points, it also deserve a lot more :=> a shell to detect several stuff as exception in the sub applet / requiered java version before launch sub-applet / start on any JRE (from old MS 1.1 to lastest Sun 1.6-u19) even if the sub applet requiere lastest and you can display a clean error message => fully free the applet at end and can even load another Applet with different jars : for example you can display a select box and ask the user wich applet he would like to load => a customizable loading process (for signed aswell as unsigned applet), this demo is not really revelant but if you test it with bigger jar ressource it will enable an imediate start of a customized loading animation while your applet is loading => enable signed / unsigned with only one warning popup alert => and finally yes also load native libraries and/or others jars at runtime (if boot.jar is signed for natives / sandard jars loading at runtime may work for unsigned)
|
|
|
|
jojoh
|
 |
«
Reply #5 - Posted
2010-04-12 23:45:03 » |
|
Looks like great improvements! => a shell to detect several stuff as exception in the sub applet / requiered java version before launch sub-applet / start on any JRE (from old MS 1.1 to lastest Sun 1.6-u19) even if the sub applet requiere lastest and you can display a clean error message
You should probably add the suggestions I added here. Mac owners seem very annoyed when their browsers freeze brutally if newer java applet version is attempted to be loaded than what is installed => have to kill browser. It would be cool if you wanted to upload your stuff to http://wiki.games4j.com/, or just let me know if you want me to do it.
|
|
|
|
DzzD
|
 |
«
Reply #6 - Posted
2010-04-12 23:56:35 » |
|
oups tryed to use the signed jar booter and found that boot.java requiere a little update to work in signed mode but the good news is that it work very well and you can load any kind of jar as long as the boot.jar is signed. code has been updated this way : 1
| URL u=new URL("jar:" + Boot.this.getClass().getResource("./" + bootArchives[n]) + "!/"); |
replaced by 1
| URL u=new URL("jar:" + Boot.this.getCodeBase() + bootArchives[n] + "!/"); |
dont even requiere any fancy MANIFEST attribute in it just execute " jarsigner -keypass yourPass boot.jar yourSelfCert" and your done
|
|
|
|
DzzD
|
 |
«
Reply #7 - Posted
2010-04-13 00:02:59 » |
|
Looks like great improvements!You should probably add the suggestions I added here. Mac owners seem very annoyed when their browsers freeze brutally if newer java applet version is attempted to be loaded than what is installed => have to kill browser. It would be cool if you wanted to upload your stuff to http://wiki.games4j.com/, or just let me know if you want me to do it. yes, sorry seems I forgot to do that last time, I will those are nice advice EDIT: @broumbroum another nice addition the applet boot bring is that once the user have accept it certificat it wont ask anymore for other applet and then if you got a website with severals signed games (even from different authors) all other will start without any security as long as you use the same applet booter @jojoh hey very nice wiki !
|
|
|
|
DzzD
|
 |
«
Reply #8 - Posted
2010-04-13 01:12:34 » |
|
arf does not seems to work as espected to mix signed/unsigned I think that a working solution is to produce a custom secured classloader inside the signed boot.jar and use it for the whole... (same as the extension loader of 3dzzd...) will look on that later  pfff... once again... thanks Oracle...
|
|
|
|
DzzD
|
 |
«
Reply #9 - Posted
2010-04-14 16:45:34 » |
|
ok this work I have implemented my own URLClassLoader that replace the current class loader the result is : if boot.jar is signed a popup will be shown and depending on user response it will load the applet jars with or without security restriction but in any case it will bring up another popup. this enable easy mixing of unsigned/signed code without the new scary popup.... here is a demo : http://demo.dzzd.net/BootV2Signed/if you answer yes than you can switch mouse look using the robot class by pressin the "M" key, you can also switch to JOGL using "H" key (hardware rendering is a little broken for this vrsion but that not the point)
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Riven
|
 |
«
Reply #10 - Posted
2010-04-14 17:01:58 » |
|
Your current solution is: - always an initial security dialog - maybe a second security dialog
What are the advantages over signing everything, where you are guaranteed to have only one security dialog?
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
DzzD
|
 |
«
Reply #11 - Posted
2010-04-14 17:11:32 » |
|
Your current solution is: - always an initial security dialog - maybe a second security dialog
What are the advantages over signing everything, where you are guaranteed to have only one security dialog?
no, just only one security dialog ( and none if you dont requiere security privilege and then dont sign the boot.jar), never two (I hope), applet booter offer a lot more and some of its advantages (not related to mixing code) are mentioned above but the one I find interresting about mixing code problem is that it does not requiere to (re)sign all the jar you use (and would become really nice if it can be signed by a real certificat, it also show how the java 6u19 about selfsigned/unsigned warning update is stupid ). but yes the real thing missing now is how to done it at runtime like before...
|
|
|
|
DzzD
|
 |
«
Reply #12 - Posted
2010-04-14 22:52:18 » |
|
some minor improvments : - adding parameter for HTML BOOTFGCOLOR to control the appearance of the rotating circle - changing catch Exception by Throwable - replace use of String.split by custom one to get back to 1.1 compatibility (not tested yet) next update will be the ability to provide a customized class (to make a custom animation while loading), this will give users full power over loading process and will finish to make this booter a very generic way. sample : http://demo.dzzd.net/BootV2/using parameters : 1 2 3 4 5 6 7
| <PARAM NAME="BOOTCLASS" VALUE="jar.MyJarApplet"> <PARAM NAME="BOOTJARS" VALUE="myJarApplet.jar;someOtherJar.jar"> <PARAM NAME="BOOTFGCOLOR" VALUE="000000"> <PARAM NAME="BOOTBGCOLOR" VALUE="ffffff"> <PARAM NAME="BOOTTOSTART" VALUE="TRUE"> <PARAM NAME="boxbgcolor" VALUE="#ffffff"> <PARAM name="java_arguments" value="-Dsun.awt.noerasebackground=true"> |
|
|
|
|
Riven
|
 |
«
Reply #13 - Posted
2010-04-14 22:56:38 » |
|
if boot.jar is signed a popup will be shown and depending on user response it will load the applet jars with or without security restriction but in any case it will bring up another popup.
no, just only one security dialog
So, what is it?
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
DzzD
|
 |
«
Reply #14 - Posted
2010-04-14 23:03:15 » |
|
oups... sorry probably my wrong english.... I suppose that I did not said what I wanted ? I was meaning : in no case / never / nada  sidenote : another interresting use of the booter now that will soon come will be the ability to provide a custom class to animate (maybe advertisment too) while loading the jar of the sub applet rather than an animated gif, for example you can imagine putting a pong game while the biggest game is loading in background EDIT: to explain better it is full replacement to the standar java loader : it is more "compatible" (work on all JRE the same no difference between java version and can provide custom loading error handling aswell as better java version checking) enable custom loading and only one security popup, boot.jar can work if it is signed aswell as it is not signed : in signed mode : there is one security popup and everything run with high privilege or in sandbox depending on user response to security popup. in unsigned mode : everything run in sandbox (inded without security popup) in both mode jars are loaded in background and it can work with all existing applet without the need to recompile them (only requiere HTML modification)
|
|
|
|
Abuse
|
 |
«
Reply #15 - Posted
2010-04-15 01:12:32 » |
|
Is this meant to be broken atm? 'cos it doesn't appear to be working as expected in 1.6.0_18. I get this to the console: Adding JAR jar:http://demo.dzzd.net/BootV2/myJarApplet.jar!/ Adding JAR jar:http://demo.dzzd.net/BootV2/someOtherJar.jar!/ MyJarApplet.init() MyJarApplet.start() MyJarApplet.paint() MyJarApplet.paint() But no applet repainting occurs at all. I guess it's a problem with the Applet being launched rather than your Applet booter itself; What's the Applet supposed to do?
|
|
|
|
DzzD
|
 |
«
Reply #16 - Posted
2010-04-15 08:22:12 » |
|
it just display a blue message over a white screen, but maybe you try while I was updating (my fault, one version was drawing a white text over a white background....)? yours logs seems to show that it have worked well : started the sub applet and paint it.
maybe it is related to a graphic problem try to drag a window over the applet plz to see if it help
|
|
|
|
princec
|
 |
«
Reply #17 - Posted
2010-04-15 09:09:48 » |
|
Worked perfectly for me with u18 - in Opera 10.5 (shock horror!) And very nice and fast too. Still not as seamless as Flash though. Cas 
|
|
|
|
jojoh
|
 |
«
Reply #18 - Posted
2010-04-15 10:48:30 » |
|
But no applet repainting occurs at all.
The white background isn't repainted for me, but the text is, so swapping windows will just display the blue text on whatever was on the screen on that place before. But I guess it is not the cool text you are showing of, but the boot loader  Boot loader works fine, but suffers from the same problem I think (Scrolling, moving browser or alt-tabbing will "smear" the loading animation/screen (now loading so fast I can't test, but was like that before). Could be solved by drawing on an image and then drawing the image to the container => slightly more CPU use and a slightly larger boot loader. WinXP, 1.6.0_19, FF 3.5.9 I have already done a hack like that, I might upload the code later if anybody wants it, but it is a slight tradeoff. DzzD, do you want to add a page on the wiki for this. Forum is great for discussion and wiki is great for conclusions (or at least the latest version). The applet section in the [size=15pt] Wiki[/size] would be a good place. Just similar to your initial post in the thread. Wiki or it didn't happen FTW! 
|
|
|
|
DzzD
|
 |
«
Reply #19 - Posted
2010-04-16 15:18:14 » |
|
I will put the final version on the Wiki, it requiere just a little last improvment I would like to add :
the ability to add a custom class for the boot animation & error (given in an HTML parameter).
it will have to extends an interface like BootHandler this will make the boot.jar usable (without the need to always modify its source).
If no BootHandler is provided than it will load as it does currently, but if a BootHandler is provided it will be notified on loading (and will be able to paint while loading) it will also notified about error and more
|
|
|
|
|
DzzD
|
 |
«
Reply #21 - Posted
2010-05-01 09:17:37 » |
|
thks, this class is not requiere for unsigned Applet just remove this line "ucl = new BootClassLoader ( urlJars );" and the associated try...catch anyway here is its source code, it is intended to give full right to the applet to enable the use of signed/unsigned jars in the archive PARAM of the applet with only one security popup (wich appear if boot.jar is signed) BootClassLoader .java1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import java.net.*; import java.security.*;
public class BootClassLoader extends URLClassLoader { public BootClassLoader(URL[] urls) { super(urls); Thread.currentThread().setContextClassLoader( this ); System.setSecurityManager(new MySecurityManager()); } private class MySecurityManager extends SecurityManager { public MySecurityManager() { super(); }
public void checkPermission(Permission perm) throws SecurityException, NullPointerException { }
public void checkPermission(Permission perm, Object context) throws SecurityException, NullPointerException { } } } |
|
|
|
|
CommanderKeith
|
 |
«
Reply #22 - Posted
2010-05-01 09:47:50 » |
|
Thanks a lot, very neat. Mind if I ask a few questions? Is this correct: a. the Boot applet loads itself and paints the loading graphic. b. While painting, it downloads the other jars using URLClassLoader. c. Once downloaded, the applet 'a' is setup to have the same state as the boot applet, including size, AppletStub, etc. d. Then the Applet a is added to the boot applet's inner java.awt.Container, e. and then thread that was painting the boot applet is stopped. Another thing, while I haven't seen the default java coffee cup loading logo on your demo applet, isn't there a chance it will be displayed while the initial boot.jar is downloaded? Thanks Bruno, great work here  Keith
|
|
|
|
DzzD
|
 |
«
Reply #23 - Posted
2010-05-01 10:06:40 » |
|
happy you found it usefull  you're alright about the process, another step is that the boot applet component is removed from its parent container when the sub-applet "a" is added Another thing, while I haven't seen the default java coffee cup loading logo on your demo applet, isn't there a chance it will be displayed while the initial boot.jar is downloaded?
there is few chance yes but it will never be show for a long time, inded it is better to let an image parameter to the applet : a plain color image (image file size will just be few bytes) as the html web page background color maybe nice to replace in some case (when it is working) the few seconds java plugin loading animation NB: something that should really be added is setUncaucghtExceptionHandler to the thread that load the applet a , so you can do something when the applet crash like display the user a message to propose to restart the applet or to send a bug report or anything else
|
|
|
|
CommanderKeith
|
 |
«
Reply #24 - Posted
2010-05-01 10:14:16 » |
|
there is few chance yes but it will never be show for a long time, inded it is better to let an image parameter to the applet : a plain color image (image file size will just be few bytes) as the html web page background color maybe nice to replace in some case (when it is working) the few seconds java plugin loading animation
I've been trying to get a custom loading image to show up but haven't succeeded, it just shows a grey background with no loading graphic - not the default one or the gif i told it to use. By the way, tt the start of the run() method you have a short sleep, what is that for? 1 2 3 4
| public void run() { try { Thread.sleep(100); String bootArchive = Boot.this.getParameter("BOOTJARS"); |
Keith 
|
|
|
|
DzzD
|
 |
«
Reply #25 - Posted
2010-05-01 10:31:03 » |
|
as I remember the sleep was to test the loader (have some time to see what the loading look like), It can be safely removed. probably the image take some time to load, try to make the boot.class implements ImageObserver and in the ImageObserver updateImage method do your image paint and return !this.isLoaded so it will be called periodically for animated gif until applet is loaded.
also remember that you must use parent graphics stored in this.g or this.c.getGraphics() and that if the anim thread is running (the one who draw the circle) it will paint over your gif
|
|
|
|
CommanderKeith
|
 |
«
Reply #26 - Posted
2010-05-01 10:38:49 » |
|
Thanks a lot for your help, I'll try it out 
|
|
|
|
jojoh
|
 |
«
Reply #27 - Posted
2010-05-02 01:55:50 » |
|
I use a modified version of this boot loader [size=12pt] here[/size]. I haven't added the plugin replacement image, but I never see the spinning java logo, but it can be because I "sit so close to the server". Would be interesting to hear how it loads for you. I could also show the code, if that is what you wanted to do, but I think that DzzD planned to do something better than what I have done, so I was actually planning to replace my code with his when that is done. The plan is then to use the same boot loader for all java games on the site, so that the loader will appear really fast.
|
|
|
|
CommanderKeith
|
 |
«
Reply #28 - Posted
2010-05-02 06:09:50 » |
|
I use a modified version of this boot loader [size=12pt] here[/size]. I haven't added the plugin replacement image, but I never see the spinning java logo, but it can be because I "sit so close to the server". Would be interesting to hear how it loads for you. I get a page with a blank space where the applet should be for about 15 seconds, then the loading image fires up then the game starts. I think the long initial delay is because in your applet tag you put all the jars in the 'archive' parameter which means that they are all downloaded. In DzzD's latest version only the small boot.jar is in the archive, the other jars are downloaded by the URLClassLoader while the animation is shown. Here's a demo I made using the boot loader code: http://keithphw.freehostia.com/LineOfSightApplet/This is what I see when I load it: The java coffee cup for a second, but sometimes it's not shown which is good. Then the spinning white animation of the boot.jar. Then that animation freezes for about 5 seconds until the main applet starts painting. It's unfortunate about that 5 second freeze. It occurs because my main applet takes ages to execute the code in the constructor and the thread seems to take a very long time to start - which is strange because when it is run as a normal app in a JFrame rather than an Applet it starts instantly... weird  PS: I added AppletBoot.this.a.invalidate(); and AppletBoot.this.a.validate(); after the call to AppletBoot.this.a.resize(new Dimension(AppletBoot.this.w(), AppletBoot.this.h())); to get everything to lay itself out properly.
|
|
|
|
jojoh
|
 |
«
Reply #29 - Posted
2010-05-03 01:11:21 » |
|
I get a page with a blank space where the applet should be for about 15 seconds, then the loading image fires up then the game starts. I think the long initial delay is because in your applet tag you put all the jars in the 'archive' parameter which means that they are all downloaded. In DzzD's latest version only the small boot.jar is in the archive, the other jars are downloaded by the URLClassLoader while the animation is shown.
Thanks for the report! It looked so good from here I was almost starting to think that some magic happened to make the preloading happen during the loading animation. I have not been able to use v2 of the boot, because I can't access resources as I used to. 1
| Thread.currentThread().getContextClassLoader().getResourceAsStream(resource) |
dosen't find the stuff from "BOOTJARS". The console just freezes, but I think that is the problem. I guess they are only available from another thread/classloader. Not sure if I made some mistake somewhere along the line. Suggestions are welcome. I guess it might be time for me to learn about classloaders... It's unfortunate about that 5 second freeze. It occurs because my main applet takes ages to execute the code in the constructor and the thread seems to take a very long time to start - which is strange because when it is run as a normal app in a JFrame rather than an Applet it starts instantly... weird  Pretty cool applet  It seems like it loads some more things after the start of the applet: 1 2 3 4 5 6 7
| LineOfSightApplet: contructor begin network: Cache entry not found [url: http: network: Connecting http: network: Connecting http: . . . |
|
|
|
|
|