SWT Tips and Samples 基礎編 > Table |
|
TableSWTのTableはSwingのテーブルに比べ容易に実装が可能です。TableのコンストラクタでTableの振る舞いや表示を指定することができます。 SWTが提供しているTableは、 非常にシンプルで使いやすいのですが、モデルとビューを切り分けてTableを使った実装をしたいときは、JFaceライブラリに用意されているTableViewerクラスを利用することをお勧めします。 詳しくは、下の参考リンクを参照してください。 スクリーンショットソースコード (TableLayoutTest.java)import org.eclipse.swt.SWT; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class TableTest { public static void main(String[] args) { new TableTest(); } public TableTest() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("TableTest"); shell.setLayout(new FillLayout()); Table table1 = new Table(shell, SWT.MULTI | SWT.BORDER); table1.setHeaderVisible(true); createTableColAndContents(table1); Table table2 = new Table(shell, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); table2.setLinesVisible(true); createTableColAndContents(table2); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } private void createTableColAndContents(Table table){ for (int i=0; i<4; i++){ TableColumn col = new TableColumn(table, SWT.LEFT); col.setText("Col" + i); col.setWidth(60); } for (int i=0; i<10; i++){ String [] contents = {"Item0-" + i, "Item1-" + i, "Item2-" + i, "Item3-" + i}; TableItem tableItem = new TableItem(table, SWT.NONE); tableItem.setText(contents); } } } 参考
最新更新日: 2004年10月20日 |
- PR -
【Sony】大手他社よりも安い!ビジネス向け光・100Mしかも固定IP付!今なら更に初期費用最大15,000円OFF!
オフィス用品・オフィス家具 価 格 交 渉 可!
|
||||
|
|||||
Copyright(C) 2003,2004 Jasmin Project. All Right Reserved. |
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||