Swt/Jface进度条

普通的进度条
None.gif import  java.lang.reflect.InvocationTargetException;
None.gif
None.gif
import  org.eclipse.core.runtime.IProgressMonitor;
None.gif
import  org.eclipse.jface.dialogs.ProgressMonitorDialog;
None.gif
import  org.eclipse.jface.operation.IRunnableWithProgress;
None.gif
import  org.eclipse.swt.widgets.Display;
None.gif
import  org.eclipse.swt.widgets.Shell;
None.gif
None.gif
ExpandedBlockStart.gifContractedBlock.gif
public   class  TestProgress  dot.gif {
InBlock.gif    
static boolean stopflg = false;
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/** *//**
InBlock.gif     * Launch the application
InBlock.gif     * 
@param args
ExpandedSubBlockEnd.gif     
*/

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

InBlock.gif                    monitor.worked(
1);
InBlock.gif                    Thread.sleep(
50);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
InBlock.gif                monitor.done();
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }
;
InBlock.gif        
new ProgressMonitorDialog(shell).run(truetrue, runnable);
InBlock.gif        shell.open();
InBlock.gif        shell.layout();
ExpandedSubBlockStart.gifContractedSubBlock.gif        
while (!shell.isDisposed()) dot.gif{
InBlock.gif            
if (!display.readAndDispatch())
InBlock.gif                display.sleep();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedBlockEnd.gif}

None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值