Hello JFace
- 프로그래밍/SWT & JFace
- 2016. 1. 6. 14:01
Hello JFace
JFace Project 생성 및 Hello JFace 어플리케이션 작성
내용
- JFace ApplicationWindow 자동생성
- Hello JFace 어플리케이션 작성
Example
SWT/JFace Project를 생성 > New > Ohter
ApplicationWindow선택
아니면, 일반 Class를 생성하고 org.eclipse.jface.window.ApplicationWindow 를 상속해도 결과는 동일
ApplicationWindow로 선택하여 Class를 생성
일부 메소드의 Override 코딩이 템플릿으로 자동생성 된다.
[HelloJFace Class]
24~27번 까지만 작성한 내용 이고 나머지는 자동으로 생성 (window설정에 대한 초기화 부분을 자동으로 생성해 주었다고 생각하자)
main 메소드를 포함하고 있어서 바로 실행이 가능하다. (별도 분리 가능)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import org.eclipse.jface.action.MenuManager; public class HelloJFace extends ApplicationWindow { /** * Create the application window. */ public HelloJFace() { super(null); createActions(); addToolBar(SWT.FLAT | SWT.WRAP); addMenuBar(); addStatusLine(); } /** * Create contents of the application window. * @param parent */ @Override protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); Text helloText = new Text(container, SWT.CENTER); helloText.setText("Hello JFace"); helloText.pack(); container.pack(); return container; } /** * Create the actions. */ private void createActions() { // Create the actions } /** * Create the menu manager. * @return the menu manager */ @Override protected MenuManager createMenuManager() { MenuManager menuManager = new MenuManager("menu"); return menuManager; } /** * Create the toolbar manager. * @return the toolbar manager */ @Override protected ToolBarManager createToolBarManager(int style) { ToolBarManager toolBarManager = new ToolBarManager(style); return toolBarManager; } /** * Create the status line manager. * @return the status line manager */ @Override protected StatusLineManager createStatusLineManager() { StatusLineManager statusLineManager = new StatusLineManager(); return statusLineManager; } /** * Launch the application. * @param args */ public static void main(String args[]) { try { HelloJFace window = new HelloJFace(); window.setBlockOnOpen(true); window.open(); Display.getCurrent().dispose(); } catch (Exception e) { e.printStackTrace(); } } /** * Configure the shell. * @param newShell */ @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("New Application"); } /** * Return the initial size of the window. */ @Override protected Point getInitialSize() { return new Point(450, 300); } } | cs |
수행결과
다운로드
같이보기
'프로그래밍 > SWT & JFace' 카테고리의 다른 글
SWT/JFace Layout (0) | 2016.02.15 |
---|---|
JFace Event처리 (Action and Contribution) (0) | 2016.02.12 |
SWT Event 처리 (Event and Listener) (0) | 2016.02.11 |
TabFolder를 이용하여 탭화면 구성하기 (0) | 2016.02.10 |
화면에 표시되는 주요 클래스 구조 Widget/Control/Composite (0) | 2016.01.17 |
SWT/JFace 기본 동작 구조 (2) | 2016.01.11 |
Hello SWT (0) | 2016.01.06 |
SWT/JFace 기본개념 및 개발환경 구축 (0) | 2016.01.06 |
이 글을 공유하기