<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
    主站蜘蛛池模板: 91福利免费视频| 久久黄色免费网站| 成人人观看的免费毛片| 亚洲日韩国产精品无码av| 亚洲一区免费观看| 久久精品国产精品亚洲艾草网| 狠狠躁狠狠爱免费视频无码| 在线观看国产区亚洲一区成人| 国产激情久久久久影院老熟女免费 | 久久精品国产亚洲麻豆| eeuss草民免费| 亚洲码国产精品高潮在线| 亚洲日韩在线观看免费视频| 亚洲中文字幕无码久久综合网| 中国一级全黄的免费观看| 久久亚洲国产视频| 1000部拍拍拍18免费网站| 亚洲人成综合网站7777香蕉| 成年私人影院免费视频网站| 久久亚洲精品无码av| 亚洲第一成人影院| 最新亚洲成av人免费看| 亚洲午夜久久影院| 四虎永久在线观看免费网站网址| 亚洲精品动漫免费二区| 久久久久无码专区亚洲av| 久久免费动漫品精老司机| 亚洲欧洲日本在线观看| 少妇亚洲免费精品| 免费视频成人手机在线观看网址| 亚洲激情视频网站| 又黄又爽一线毛片免费观看| 久久久久国色AV免费观看| 亚洲成年人电影网站| 国产乱子伦精品免费女| 久久国产乱子伦精品免费看| 亚洲综合一区无码精品| 亚洲精品夜夜夜妓女网 | 成人激情免费视频| 一级毛片完整版免费播放一区| 亚洲AV美女一区二区三区|