Hello everyone, The porblem is in the double buffering (createImage(int x,int y) method). The problem occur when i closed and open the Applet again and again and it sometime give the SecurityException.the java Console message is. java.lang.SecurityException: Too many images at com/ms/awt/image/ImageRepresentation.incNativeCount at com/ms/awt/image/ImageRepresentation.offscreenInit at com/ms/awt/image/Image.<init> at com/ms/awt/ImageX.<init> at com/ms/awt/WComponentPeer.createImage at java/awt/Component.createImage at PoolTable_Canvas.doPaint at PoolTable_Canvas.update at com/ms/awt/WComponentPeer.doUpdate at com/ms/awt/WComponentPeer.doUpdate at com/ms/awt/WUpdate.run at com/ms/ui/windowmanager/RunnableMessage.run at com/ms/awt/WSystemQueue.getMessage at com/ms/awt/WEventQueue.getNextEvent at java/awt/EventDispatchThread.run .please give ur suggestios too prevent this Exception as early as possible. Thanks
This simply means that the VM's GC is not doing a proper job... What you should dois try to nullyfy all the reference & dispose () all the frame not used. You probably should spend some tedious time (but also quiet exciting ) in trapping all the WindowEvent to add some code to do that ! I should really help the VM doing it's job ! One question though, I sthis always after a fixed number of Open / close or the faster the sooner. In the first case you really have some de-allocation problem. In the latter, the trick should definitively help ! Complete explainationis here. Thomas,
Make sure that the Image you use for double-buffering is kept in a member variable of the class and is only created once, not everytime you enter the paint method. I usually have something like this:
You might think that the checking if bufferImage and imageGraphics are null is superfluous, but it is possible for these to end up as being null if the system is running low on resources. Of course, you would probably want to display an error of some sort in this case.
David G. Risner<br />Software Engineer<br />California State University, Los Angeles
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop