Hello JFace


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(450300);
    }
 
}
 
cs


수행결과




다운로드

HelloJFace.zip


같이보기

SWT/JFace 개발환경 구축

Hello SWT


이 글을 공유하기

댓글

Email by JB FACTORY