1
對於SWT來說更新。我必須編寫一個顯示進度條的方法。如果我打電話的方法。我應該通過時間和界限作爲該方法的參數。如何在swt中顯示15秒的進度條
package ProgressViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.ProgressBar;
import org.eclipse.swt.widgets.Shell;
public class PBMethod
{
private static Shell shell;
public static void Pv7(Shell shell2,final int num,final int xA,final int xB,final int xH,final int xW)
{
shell=shell2;
final ProgressBar bar = new ProgressBar(shell, SWT.NONE);
bar.setSize(1500, 1000);
shell.setLayout(new GridLayout());
shell.setSize(1500, 1000);
final Thread thread = new Thread()
{
public void run()
{
for(int i=0; i<=num; i++)
{
final int value = i;
try
{
Thread.sleep(50);
}
catch (Exception e){}
shell.getDisplay().asyncExec(new Runnable()
{
public void run()
{
bar.setBounds(xA,xB,xH,xW);
bar.setSelection(value);
}
});
}
shell.getDisplay().syncExec(new Runnable()
{
public void run()
{
bar.dispose();
MessageBox dialog1 = new MessageBox(shell, SWT.NONE| SWT.OK| SWT.CANCEL);
dialog1.setText("Information");
dialog1.setMessage("Saved Successfully");
dialog1.open();
}
});
}
};
thread.start();
}
}
這裏此上述方法使邊界和的百分比..但不是時間..進度條應該顯示10秒..或15秒..我應該在唯一的參數給..
但在發送的代碼中,第二個參數用於完成進度條的百分比。 參數應該在顯示進度查看器時傳遞,例如10 10秒。如果我們想將其更改爲15,則應只更改參數值。
幫助將會感激!
感謝您的評論@ Jprogrammer – afu