Find the icon of the program that edits .bmp files : WIN32 « SWT JFace Eclipse « Java






Find the icon of the program that edits .bmp files

Find the icon of the program that edits .bmp files


/*
 * Program example snippet: find the icon of the program that edits .bmp files
 *
 * For a list of all SWT example snippets see
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
 */
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class Snippet32 {

public static void main (String [] args) {
  Display display = new Display ();
  Shell shell = new Shell (display);
  Label label = new Label (shell, SWT.NONE);
  label.setText ("Can't find icon for .bmp");
  Image image = null;
  Program p = Program.findProgram (".bmp");
  if (p != null) {
    ImageData data = p.getImageData ();
    if (data != null) {
      image = new Image (display, data);
      label.setImage (image);
    }
  }
  label.pack ();
  shell.pack ();
  shell.open ();
  while (!shell.isDisposed()) {
    if (!display.readAndDispatch ()) display.sleep ();
  }
  if (image != null) image.dispose ();
  display.dispose ();
}

} 


           
       








Related examples in the same category

1.Invoke the system text editor on autoexec.bat
2.Place an icon with a popup menu on the system trayPlace an icon with a popup menu on the system tray
3.SWT Ole FrameSWT Ole Frame
4.OLE and ActiveX example snippet
5.Word OLEWord OLE
6.Invoke an external batch fileInvoke an external batch file
7.Running a script within IE.Running a script within IE.
8.Reading and writing to a SAFEARRAY
9.Embed Word in an applet
10.OLE and ActiveX example: browse the typelibinfo for a program id
11.OLE and ActiveX example: get events from IE controlOLE and ActiveX example: get events from IE control
12.How to access About, Preferences and Quit menus on carbon