package com.impart.kurs.swt;

import java.net.URL;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Main {
	public void open(){
		final Display display = new Display();
		final Shell shell = new Shell();

		shell.setSize(300, 200);
		shell.setText("Uebung 1");
		
		//URL imgUrl=this.getClass().getResource("myapp.gif");
		URL imgUrl=Thread.currentThread().getContextClassLoader().getResource("icons/myapp.gif");

		URL imgUrl2=this.getClass().getResource("icons/myapp.gif");

		Image img=new Image(display,imgUrl.getPath());
		shell.setImage(img);
		
		shell.open();
		while (!shell.isDisposed()) {
			
			if (!display.readAndDispatch())
				display.sleep();
		}
		
		img.dispose();
		display.dispose();
	}

	public static void main(String[] args) {
		Main window=new Main();
		window.open();
	}
}
