プログレスバーは処理の進捗をあらわすためのウィジェットです。
import org.eclipse.swt.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class ProgressBarSample1 { public static void main (String [] args) { Display display = new Display (); Shell shell =new Shell(display); shell.setText("ProgressBar Sample1"); shell.setLayout(new FillLayout()); ProgressBar progbar = new ProgressBar(shell,SWT.NULL); progbar.setMinimum(0); progbar.setMaximum(9999); shell.setSize(400,40); shell.open(); for(int i=0;i<10000;i++){ progbar.setSelection(i); } while (!shell.isDisposed ()){ if (!display.readAndDispatch ()){ display.sleep (); } } display.dispose (); } }
コンストラクタのスタイル指定でSWT.SMOOTHを指定するとバーの表示がなめらかになります。
// スムーズなプログレスバー ProgressBar progbar = new ProgressBar(shell,SWT.SMOOTH);
最終更新時間:2004年03月09日 03時48分52秒