Пример #1
0
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setLayout(new org.eclipse.swt.layout.FillLayout());
   shell.setText(getResourceString("window.title"));
   java.io.InputStream stream =
       (org.eclipse.swt.examples.browserexample.BrowserExample.class)
           .getResourceAsStream(iconLocation);
   org.eclipse.swt.graphics.Image icon = new org.eclipse.swt.graphics.Image(display, stream);
   shell.setImage(icon);
   try {
     stream.close();
   } catch (java.io.IOException e) {
     e.printStackTrace();
   }
   org.eclipse.swt.examples.browserexample.BrowserExample app =
       new org.eclipse.swt.examples.browserexample.BrowserExample(shell, true);
   app.setShellDecoration(icon, true);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   icon.dispose();
   app.dispose();
   display.dispose();
 }
Пример #2
0
 void initResources() {
   final java.lang.Class clazz = this.getClass();
   if (resourceBundle != null) {
     try {
       if (images == null) {
         images = new org.eclipse.swt.graphics.Image[imageLocations.length];
         for (int i = 0; i < imageLocations.length; ++i) {
           java.io.InputStream sourceStream = clazz.getResourceAsStream(imageLocations[i]);
           org.eclipse.swt.graphics.ImageData source =
               new org.eclipse.swt.graphics.ImageData(sourceStream);
           org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
           images[i] = 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);
 }
Пример #3
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);
 }
Пример #4
0
 public org.eclipse.swt.widgets.Shell open(org.eclipse.swt.widgets.Display display) {
   java.lang.Class clazz = org.eclipse.swt.examples.hoverhelp.HoverHelp.class;
   try {
     if (images == null) {
       images = new org.eclipse.swt.graphics.Image[imageLocations.length];
       for (int i = 0; i < imageLocations.length; ++i) {
         java.io.InputStream stream = clazz.getResourceAsStream(imageLocations[i]);
         org.eclipse.swt.graphics.ImageData source =
             new org.eclipse.swt.graphics.ImageData(stream);
         org.eclipse.swt.graphics.ImageData mask = source.getTransparencyMask();
         images[i] = new org.eclipse.swt.graphics.Image(display, source, mask);
         try {
           stream.close();
         } catch (java.io.IOException e) {
           e.printStackTrace();
         }
       }
     }
   } catch (java.lang.Exception ex) {
     System.err.println(
         getResourceString(
             "error.CouldNotLoadResources", new java.lang.Object[] {ex.getMessage()}));
     return null;
   }
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell();
   createPartControl(shell);
   shell.addDisposeListener(
       new org.eclipse.swt.events.DisposeListener() {
         public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
           if (images != null) {
             for (int i = 0; i < images.length; i++) {
               final org.eclipse.swt.graphics.Image image = images[i];
               if (image != null) {
                 image.dispose();
               }
             }
             images = null;
           }
         }
       });
   shell.pack();
   shell.open();
   return shell;
 }