<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 4  文章 - 10  trackbacks - 0
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(1)

    隨筆檔案

    文章分類

    文章檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    處理長時間的任務的時候常需要進度條顯示,有幾種實現方式
    1,普通的進度條
    import java.lang.reflect.InvocationTargetException;

    import org.eclipse.core.runtime.IProgressMonitor;
    import org.eclipse.jface.dialogs.ProgressMonitorDialog;
    import org.eclipse.jface.operation.IRunnableWithProgress;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;


    public class TestProgress {
        
    static boolean stopflg = false;
        
    /**
         * Launch the application
         * 
    @param args
         
    */

        
    public static void main(String[] args) throws Exception{
            
    final Display display = Display.getDefault();
            
    final Shell shell = new Shell();
            shell.setSize(
    500375);
            shell.setText(
    "SWT Application");
            
            
    //
            IRunnableWithProgress runnable = new IRunnableWithProgress(){
                
    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(
    "generate"30);
                    
    for(int i=0;i<100;i++){
                        
    if(monitor.isCanceled()){
                            
    return;
                        }

                        monitor.worked(
    1);
                        Thread.sleep(
    50);
                    }

                    
                    monitor.done();
                }

            }
    ;
            
    new ProgressMonitorDialog(shell).run(truetrue, runnable);
            shell.open();
            shell.layout();
            
    while (!shell.isDisposed()) {
                
    if (!display.readAndDispatch())
                    display.sleep();
            }

        }


    }

    2,反復循環的進度條
    import java.lang.reflect.InvocationTargetException;

    import org.eclipse.core.runtime.IProgressMonitor;
    import org.eclipse.jface.dialogs.ProgressMonitorDialog;
    import org.eclipse.jface.operation.IRunnableWithProgress;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;


    public class TestProgress {
        
    static boolean stopflg = false;
        
    /**
         * Launch the application
         * 
    @param args
         
    */

        
    public static void main(String[] args) throws Exception{
            
    final Display display = Display.getDefault();
            
    final Shell shell = new Shell();
            shell.setSize(
    500375);
            shell.setText(
    "SWT Application");
            
            
    //
            IRunnableWithProgress runnable = new IRunnableWithProgress(){
                
    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(
    "generate"30);
                    
    int i=0;
                    
    while(true){
                        
    if(stopflg){
                            
    break;
                        }

                        i
    ++;
                        
    if(i==30){
                            i
    =0;
                            monitor.beginTask(
    "generate"30);
                        }

                        monitor.worked(
    1);
                        Thread.sleep(
    100);
                    }

                    monitor.done();
                }

            }
    ;
            
    new ProgressMonitorDialog(shell).run(truetrue, runnable);
            shell.open();
            shell.layout();
            
    while (!shell.isDisposed()) {
                
    if (!display.readAndDispatch())
                    display.sleep();
            }

        }


    }

    3,rcp中后臺任務的進度條
    使用Job建立后臺任務,只需要設置job.setUser(true)進度條就出現了,和上邊一樣,進度條需要自己來控制進度。如果做一個cool的進度條,就看你如何讓進度條顯示出實際的任務進程。
    posted on 2007-08-13 10:30 冬天出走的豬 閱讀(602) 評論(0)  編輯  收藏 所屬分類: j2se
    主站蜘蛛池模板: 少妇亚洲免费精品| 国产精品极品美女自在线观看免费| 亚洲综合小说久久另类区| 亚洲色中文字幕在线播放| igao激情在线视频免费 | 免费福利视频导航| 亚洲av高清在线观看一区二区| 久久久无码精品亚洲日韩蜜臀浪潮| 亚洲爆乳精品无码一区二区| 久久久久久AV无码免费网站下载| 国产免费观看a大片的网站| 久久亚洲中文字幕精品有坂深雪| 久久精品电影免费动漫| 免费A级毛片无码A| 亚洲国产电影在线观看| 国产精品免费看久久久香蕉 | 中文国产成人精品久久亚洲精品AⅤ无码精品| 亚洲av日韩av高潮潮喷无码| 国产成人精品亚洲| 国产福利在线免费| 亚洲精品午夜视频| 在线免费观看一级片| 亚洲经典在线观看| 拨牐拨牐x8免费| 亚洲色成人WWW永久在线观看| 蜜桃精品免费久久久久影院| 亚洲欧洲日韩在线电影| 美女被cao网站免费看在线看| 久久精品亚洲福利| 免费无码午夜福利片 | www国产亚洲精品久久久日本| yellow免费网站| 一本久久综合亚洲鲁鲁五月天| v片免费在线观看| 一区二区三区亚洲| 日韩伦理片电影在线免费观看| 亚洲精品国产综合久久久久紧| 亚洲日本中文字幕一区二区三区| 香蕉97碰碰视频免费| 四虎免费久久影院| 高清一区二区三区免费视频|