ProgressBar
ProgressBar 컨트롤은 시간이 걸리는 작업의 진행상황을 알려주는 데 사용됩니다.
▶ 예제코드
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
|
package com.swtjface.Ch5;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ProgressBar;
/**
* ProgressBar 테스트
*
* @since 2013. 6. 8.
* @author Cremazer
*
*/
public class ProgressBarTest extends ApplicationWindow {
ProgressBar bar;
int cnt = 0;
public ProgressBarTest() {
super(null);
}
public Control createContents(Composite parent) {
// --- Create the window title. ---
getShell().setText("ProgressBar Test");
bar = new ProgressBar(parent, SWT.SMOOTH);
bar.setBounds(10, 10, 200, 32);
bar.setMaximum(100);
for (int i = 0; i < 100 ; i++) {
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
setSelection();
}
});
}
return bar;
}
protected void setSelection() {
bar.setSelection((int)(bar.getMaximum() * (cnt++ +1)/100 ));
}
public static void main(String[] args) {
// --- Display CoolBarTest until the window is closed. ---
ProgressBarTest app = new ProgressBarTest();
app.setBlockOnOpen(true);
app.open();
Display.getCurrent().dispose();
}
}
|
댓글 없음:
댓글 쓰기