SWT Tips and Samples 基礎編 > TabFolder |
|
TabFolderTabFolderはタブの中にさまざまなコントロールを格納できるウィジェットです。TabFolderの中にTabItemを生成し、setControlメソッドで任意のウィジェットを格納できます。 TabFolder tab = new TabFolder(shell, SWT.NONE); Text text = new Text(tab, ...); TabItem item = new TabItem(tab, SWT.NONE); item.setText(...); item.setControl(text); また格納済みのTabItemや、選択中のTabItemを取得するには以下のようなメソッドを使います。 //格納済みのTabItemを取得 TabItem [] tabItems = tab.getItems(); //選択中のTabItemのインデックス。未選択の場合は、-1。 int index = tab.getSelectionIndex(); //格納済みのTabItem数を取得 int num = tab.getItemCount(); このTabFolder以外にも、クローズボックスを付加できるCTabFolderというウィジェットもあります。 スクリーンショットソースコード (TabFolderTest.java)import org.eclipse.swt.SWT; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class TabFolderTest { public static void main(String[] args) { new TabFolderTest(); } public TabFolderTest() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("TabFolderTest"); shell.setLayout(new FillLayout(SWT.VERTICAL)); TabFolder tab = new TabFolder(shell, SWT.NONE); Text text = new Text(tab, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); text.setText("Text"); TabItem tabItem1 = new TabItem(tab, SWT.NONE); tabItem1.setText("Tab1"); tabItem1.setControl(text); Label label = new Label(tab, SWT.NONE); label.setText("Label"); TabItem tabItem2 = new TabItem(tab, SWT.NONE); tabItem2.setText("Tab2"); tabItem2.setControl(label); shell.setSize(300,200); 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] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||