forked from stippi/MavenNativeImageSWT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.java
51 lines (42 loc) · 1.55 KB
/
App.java
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
package com.github.stippi;
import com.github.stippi.model.Document;
import com.github.stippi.ui.BrowserPanel;
import com.github.stippi.ui.DocumentPanel;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class App {
public static void main( String[] args) {
Display display = Display.getDefault();
Document document = new Document();
Shell shell = createMainWindow(document);
shell.open();
while (!shell.isDisposed()) {
display.readAndDispatch();
}
}
private static Shell createMainWindow(Document document) {
Shell shell = new Shell();
shell.setText("SWT native image demo");
createInterface(shell, document);
return shell;
}
private static void createInterface(Shell shell, Document document) {
Composite leftPanel = new DocumentPanel(shell, document);
fillGrid(leftPanel).widthHint = 100;
Composite rightPanel = new BrowserPanel(shell, document);
fillGrid(rightPanel).widthHint = 200;
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
shell.setLayout(layout);
}
private static GridData fillGrid(Control c) {
GridData data = new GridData(GridData.FILL, GridData.FILL, true, true);
c.setLayoutData(data);
return data;
}
}