E D R , A S I H C RSS

Standard Widget Toolkit

No older revisions available

No older revisions available



Eclipse의 근간이 되는 Java용 그래픽 툴킷 Eclipse 2.1 부터 공식적으로 SWT가 분리되어 배포되고 있다.
"Eclipse의 속도가 빠르다." 라는 선입견을 만들어준 장본인인 Cross Platform Native Graphic Toolkit 이다.

내부에서는 초기부터 SWT와 Eclipse 프로젝트의 역할이 분담되어, 과거 IBM developerworks 에 gcc를 이용한 프로그램 작성에 대한 문서가 있었으나, SWT를 이용한 프로그램의 등장은 보이지 않았다. 그러나 분리되면서, 그러한 프로그램을 기대할 수 있게 되었다.

SWT 프로젝트 페이지
{{|
The most succinct description of the Standard Widget Toolkit component is this:
The SWT component is designed to provide efficient, portable access to the user-interface facilities of the operating systems on which it is implemented.
--SWT 프로젝트 페이지 에서
|}}
  • SWT 2.1 문서 - Code Snippets 가 많아서, 따라하기 용이하다.

~cpp HelloWorld 를 만들어 보자.

  1. SWT를 다운로드 받는다. Eclipse downlaod에서 받을수 있다. Upload:swt-2.1-win32.zip
  2. swt.jar 를 classpath 에 잡고 다음 소스를 컴파일 한다.
    ~cpp 
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Shell;
    
    public class HelloWorld {
    	public static void main(String[] args) {
    		Display display = new Display();		
    		Shell shell = new Shell(display);
    		shell.setText("Hello World");		
    		
    		Label label = new Label(shell, SWT.NONE);		
    		label.setText("Hello World");
    		label.setBounds(20,20,100,100);							
    		
    		shell.setBounds(20,20,300,300);			 			
    		shell.open();		
    		while (!shell.isDisposed()) {
    			if (!display.readAndDispatch())
    				display.sleep();
    		}
    		display.dispose();
    	}	
    }
    
  3. 실행을 시키기 위해서, 실행되는 위치에 swt-win32-2133.dll (Windows 경우)가 있어야 한다.
  4. 실행 모습
    SWT_HelloWorld.png


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:06
Processing time 0.0235 sec