复制代码代码如下 :
import org.eclipse.swt.graphics.gc;
import org.eclipse.swt.graphics.image;
import org.eclipse.swt.graphics.rectangle;
import org.eclipse.swt.widgets.display;
import org.eclipse.swt.widgets.shell;
공개 클래스 imageshelloworld {
public static void main (String [] args) {
display = display.getDefault ();
쉘 쉘 = 새로운 쉘 ();
이미지 이미지 = 새 이미지 (디스플레이, "C : //C240B2DCC132C9C6.JPG");
shell.settext ( "imageReader");
shell.setImage (이미지);
사각형 경계 = image.getBounds ();
shell.setsize (bounds.width + 15, bounds.height +15);
shell.open ();
GC GC = 새로운 GC (쉘);
gc. drawimage (이미지, 5,5);
shell.layout ();
while (! shell.isdisposed ()) {
if (! display.readanddispatch ()) {
display.sleep ();
}
}
display.dispose ();
}
}