學(xué)習(xí)筆記1--創(chuàng)建一個(gè)簡(jiǎn)單的sheel
創(chuàng)建一個(gè)窗體需要做兩件事:
1. 生成一個(gè)Display 實(shí)例。
2. 通過(guò)在構(gòu)造函數(shù)中把Display 實(shí)例傳入,從而構(gòu)造一個(gè)Shell 實(shí)例。
下面是一個(gè)例子:
import org.eclipse.swt.widgets.*;
public class SimpleShell {
SimpleShell( ) {
Display d = new Display( );
Shell s = new Shell(d);
s.setSize(500,500);
s.open( );
while(!s.isDisposed( )){
if(!d.readAndDispatch( ))
d.sleep( );
}
d.dispose( );
}
}
在win2003系統(tǒng)中運(yùn)行上述程序,得到的界面如下圖所示。public class SimpleShell {
SimpleShell( ) {
Display d = new Display( );
Shell s = new Shell(d);
s.setSize(500,500);
s.open( );
while(!s.isDisposed( )){
if(!d.readAndDispatch( ))
d.sleep( );
}
d.dispose( );
}
}



posted on 2005-10-11 12:18 caixuetao 閱讀(233) 評(píng)論(0) 編輯 收藏