2. 목 차
SWT는?
HelloWorld 예제
WindowBuilder 소개
SWT 주요 Package
Dialog
Widget
Event
Layout
Nebulra project
팀 만들기
실습
참고자료
3. SWT는?
SWT?(StandardWidgetToolkit)
- IBM의 Stephen Northover에 의해 개발.
- SWT 버전 3.8.2(4.2.2) – 2013
- OS에 최적화 된 native library 제공
Windows, Linux, Unix, Mac OS
- www.eclipse.org/swt
4. Hello World 예제?
public static void main(String args[]) {
Display display = new Display(); // 1
Shell shell = new Shell(display); // 2
shell.setText("Hello World"); // 3
shell.setSize(300, 300); // 4
shell.open(); // 5
while (!shell.isDisposed()) // 6
if (!display.readAndDispatch()) // 7
display.sleep(); // 8
display.dispose(); // 9
}
5. Hello World 예제?
1) Display?
1) GUI 상태를 유지해주고 OS와 통신
2) Event에 대한 처리 및 관련된 곳에 전달
3) System 상수 정의.
2) Shell?
1) GUI의 최상의 윈도우
2) 시각적인 부분을 구현(Container,Widget, event
와 GUI를 연동하기 위한 연결고리)
Widget/Control/Composite
ShellClass
Display
SWTOS Class, JNI
SystemOS
6. Hello World 예제?
3) Shell의Title를 ‘HelloWorld’로 설정
4) Shell Size를 300, 300으로 설정
5) Shell을 오픈한다.
6) Shell이 종료 되지 않았으면
7) System event를 읽어서 관련 event전달
8) Event가 있을때까지 sleep
9) Display를 종료하고 프로그램을 종료한다.
9. SWT 주요 Package소개
Package명 기능
org.eclipse.swt 상수와 예외값들이 정의
SWT, SWTException, SWTError
org.eclipse.swt.widgets Wedget, Component 및 관련 Interface
org.eclipse.swt.events 이벤트, 리스너, 이벤트 타입정의
org.eclipse.swt.dnd Drag and Drop 정의
org.eclipse.swt.layout Layout 정의
org.eclipse.swt.graphics 그래픽관련 정의
org.eclipse.swt.browser
org.eclipse.swt.internal
org.eclipse.swt.opengl
** Internal package는 외부에서 클래스를 볼 수(?) 없습니다.
21. Layout 소개
RowLayout
shell.setLayout(new RowLayout());
- 주요 Property
wrap : 기본값은 true 이며, 한줄로 유지 하고 싶을 경우에 false
pack : 기본값은 true이며, 기본 contorl이 모두
justfy : 기본 값은 false이며, 부모 콘트롤 전반적으로 균등하게 배치
- RowData(Width, Height)
특정Widget의 width, height를 정의 해 줄수 있습니다.
22. Layout 소개
GridLayout
final Shell shell = new Shell();
final GridLayout gridLayout
= new GridLayout();
gridLayout.numColumns = 3;
shell.setLayout(gridLayout);
- GridData
특정Widget의 정렬방식 및 영역 채우기 등의 방법을 지정합니다.
23. Layout 소개
FormLayout
shell.setLayout (new FormLayout(););
Button button1 = new Button(shell, SWT.PUSH);
Button button2 = new Button(shell, SWT.PUSH);
Button button3 = new Button(shell, SWT.PUSH);
button1.setText("B1"); button2.setText("B2");
button3.setText("B3");
FormData data1 = new FormData();
data1.left = new FormAttachment(0,5);
data1.right = new FormAttachment(25,0);
button1.setLayoutData(data1);
FormData data2 = new FormData();
data2.left = new FormAttachment(button1,5);
data2.right = new FormAttachment(90,-5);
button2.setLayoutData(data2);
FormData data3 = new FormData();
data3.top = new FormAttachment(button2,5);
data3.bottom = new FormAttachment(100,-5);
data3.right = new FormAttachment(100,-5);
data3.left = new FormAttachment(25,5);
button3.setLayoutData(data3);