Load System File Icon : WIN32 « SWT « Java Tutorial






Load System File Icon
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.layout.RowLayout;
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 SystemFileIconLoad {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new RowLayout());

    Label label = new Label(shell, SWT.NONE);
    Image image = null;
    
    Program p = Program.findProgram(".txt");
    ImageData data = p.getImageData();
    image = new Image(display, data);
    label.setImage(image);

    p = Program.findProgram(".bmp");
    data = p.getImageData();
    image = new Image(display, data);
    label = new Label(shell, SWT.NONE);
    label.setImage(image);

    p = Program.findProgram(".doc");
    data = p.getImageData();
    image = new Image(display, data);
    label = new Label(shell, SWT.NONE);
    label.setImage(image);
    
    
    label.pack();
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    if (image != null)
      image.dispose();
    display.dispose();
  }

}








17.127.WIN32
17.127.1.Using System Icon ImageUsing System Icon Image
17.127.2.Invoke the system text editor on autoexec.bat
17.127.3.Invoke an external batch file
17.127.4.Load System File IconLoad System File Icon
17.127.5.Embed Word in an applet (win32 only)
17.127.6.OLE and ActiveX: browse the typelibinfo for a program id (win32 only)
17.127.7.OLE and ActiveX: get events from IE control (win32 only)OLE and ActiveX: get events from IE control (win32 only)
17.127.8.How to access About, Preferences and Quit menus on carbon.
17.127.9.Add System Setting Change Listener
17.127.10.Detect a system settings changeDetect a system settings change