📄 progressmonitordialog4.java
字号:
package cn.com.chengang.jface.dialog.loopprogressdialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class ProgressMonitorDialog4 {
public static void main(String[] args) {
new ProgressMonitorDialog4().open();
}
public void open() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setSize(500, 375);
shell.setLayout(new RowLayout());
Button button = new Button(shell, SWT.NONE);
button.setText(" GO ");
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
new LoopImageDialog(shell).run(true, new IProgressDialogRunnable() {
public void run(BooleanFlag stopFlag) {
for (int i = 0; i < 10; i++) {
System.out.println("第" + (i + 1) + "个任务执行完毕");
if (stopFlag.getFlag()) {
System.out.println("被中断了");
return;
}
try {
Thread.sleep(1000);
} catch (Throwable t) {}
}
stopFlag.setFlag(true);
System.out.println("全部任务执行完毕");
}
});
}
});
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -