Example #1
0
 /** Loads the image resources. */
 public void initResources() {
   final Class clazz = PaintExample.class;
   if (PaintExample.resourceBundle != null)
     try {
       for (int i = 0; i < PaintExample.tools.length; ++i) {
         Tool tool = PaintExample.tools[i];
         String id = tool.group + '.' + tool.name;
         InputStream sourceStream =
             clazz.getResourceAsStream(PaintExample.getResourceString(id + ".image"));
         ImageData source = new ImageData(sourceStream);
         ImageData mask = source.getTransparencyMask();
         tool.image = new Image(null, source, mask);
         try {
           sourceStream.close();
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
       return;
     } catch (Throwable t) {
     }
   String error =
       PaintExample.resourceBundle != null
           ? PaintExample.getResourceString("error.CouldNotLoadResources")
           : "Unable to load resources";
   freeResources();
   throw new RuntimeException(error);
 }
Example #2
0
 /** Frees the resource bundle resources. */
 public void freeResources() {
   for (int i = 0; i < PaintExample.tools.length; ++i) {
     Tool tool = PaintExample.tools[i];
     final Image image = tool.image;
     if (image != null) image.dispose();
     tool.image = null;
   }
 }