SWT Tips and Samples 基礎編 > GridLayout |
|
GridLayoutGridLayoutは格子状にコンポーネントを配置するレイアウトです。HTMLのテーブルタグの感覚で配置します。配置する格コンポーネントのレイアウト情報は、GridData経由で設定します。GridLayoutで注意しなければいけないのは、SWTの仕様上GridDataのインスタンスを再利用してはいけないということです。再利用すると正しくレイアウトが表示されません。スクリーンショットソースコード (GridLayouTest.java)import org.eclipse.swt.SWT; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class GridLayoutTest { public static void main(String[] args) { new GridLayoutTest(); } public GridLayoutTest() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("GridLayoutTest"); GridLayout layout = new GridLayout(); layout.numColumns = 3; shell.setLayout(layout); GridData gd = null; new Button(shell, SWT.PUSH).setText("Button1"); new Button(shell, SWT.PUSH).setText("Button2"); new Button(shell, SWT.PUSH).setText("Button3"); Button b4 = new Button(shell, SWT.PUSH); b4.setText("Button4"); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; b4.setLayoutData(gd); new Button(shell, SWT.PUSH).setText("Button5"); Button b6 = new Button(shell, SWT.PUSH); b6.setText("Button6"); gd = new GridData(GridData.FILL_BOTH); gd.verticalSpan = 2; b6.setLayoutData(gd); new Button(shell, SWT.PUSH).setText("Button7"); new Button(shell, SWT.PUSH).setText("Button8"); new Button(shell, SWT.PUSH).setText("Button9"); new Button(shell, SWT.PUSH).setText("Button10"); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } } 参考
最新更新日: 2004年9月1日 |
- PR -
【Sony】大手他社よりも安い!ビジネス向け光・100Mしかも固定IP付!今なら更に初期費用最大15,000円OFF!
オフィス用品・オフィス家具 価 格 交 渉 可!
|
||||
|
|||||
Copyright(C) 2003,2004 Jasmin Project. All Right Reserved. |
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||