Archived

This topic is now archived and is closed to further replies.

Infin

[java] A problem with Applets

Recommended Posts

Infin    122
I''m having a serious problem with Applets, and I''ve spent 2 days trying to solve it. I can''t find any info on this issue so I turn myself over to your expert hands. I have a class, Gamelet which extends applet. In the init() it has this code block:
if(getGraphicsConfiguration().getImageCapabilitie().isAccelerated())
               {
                    createBufferStyle(BUFFER_STYLE_ACCELERATED);
               }
 
It''s supposed to determine which sort of back buffer to create. But, for some reason, getGraphicsConfiguration() always returns null. The javaDoc says the getGraphicsConfiguration() should only return null if the applet isn''t being contained in a component. But I don''t understand why an applet would need to have a parent component? I want my Gamelet to be stand-alone, yet I need the graphicsConfig. information; please, if anybody can help me, give me a hint! Note: I''ve been trying to run this code in the AppletViewer of JBuilder 6, and I''m starting to suspect that that could be the reason, but I wasn''t able to set up the HTML file so that it could find the class. But one problem at a time right? Thanks in advance. -Infin.

Share this post


Link to post
Share on other sites
Infin    122
Thanks alot! That did just the trick, though I''m still wondering why the error occured in the first place.

Thanks fractionMan.

Share this post


Link to post
Share on other sites
fractionMan    122
It''s something to do with the way the broswer loads the applet, and it''s linked in with the reasons why you don''t use the constructor of an applet to do anything.

I believe that the browser uses some kind of appletstub class to call an applets methods. It''s not until after you have left the init() method that you can reach out and use things like images. (and a couple of other things I can;t quite remember)

Share this post


Link to post
Share on other sites