示例#1
0
 public void initResources() {
   final java.lang.Class clazz = org.eclipse.swt.examples.paint.PaintExample.class;
   if (resourceBundle != null) {
     try {
       for (int i = 0; i < tools.length; ++i) {
         org.eclipse.swt.examples.paint.Tool tool = tools[i];
         java.lang.String id = tool.group + '.' + tool.name;
         java.io.InputStream sourceStream =
             clazz.getResourceAsStream(getResourceString(id + ".image"));
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(sourceStream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         tool.image = new org.eclipse.swt.graphics.Image(null, source, mask);
         try {
           sourceStream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
       return;
     } catch (java.lang.Throwable t) {
     }
   }
   java.lang.String error =
       resourceBundle != null
           ? getResourceString("error.CouldNotLoadResources")
           : "Unable to load resources";
   freeResources();
   throw new java.lang.RuntimeException(error);
 }
示例#2
0
 public void freeResources() {
   for (int i = 0; i < tools.length; ++i) {
     org.eclipse.swt.examples.paint.Tool tool = tools[i];
     final org.eclipse.swt.graphics.Image image = tool.image;
     if (image != null) {
       image.dispose();
     }
     tool.image = null;
   }
 }