Tips > SashFormに配置したウィジェットを最大化する |
|
SashFormに配置したウィジェットを最大化するSashFormに配置したウィジェットは、SashForm内で最大化することができます。具体的には、SashFormのsetMaximizedControl()メソッドに、最大化したいウィジェットを引数として渡します。また元に戻す(リストア)するには、nullを引数として与えます。 SashForm sash = new SashForm(...); Button b1 = new Button(sash, ...); //ウィジェットを最大化する sash.setMaximizedControl(b1); //最大化したウィジェットを元に戻す sash.setMaximizedControl(null); //最大化してあるウィジェットを取り出す Control c = sash.getMaximizedControl(); サンプルプログラムSashFormに配置した3つのViewFormのタイトル部分をダブルクリックすると、ViewFormが最大化されます。元に戻すには、もう一度タイトル部分をダブルクリックします。ソースコードでは、タイトルバーがダブルクリックされるとmaximizeHelperメソッドが呼び出され、ここで最大化、リストアの処理が行われています。 ソースコード (MaximizableSashForm.java)import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ViewForm; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class MaximizableSashForm { public static void main(String[] args) { new MaximizableSashForm(); } public MaximizableSashForm() { Display display = new Display(); Shell shell = new Shell(display); shell.setText("MaximizableSashForm"); shell.setLayout(new FillLayout()); SashForm sash = new SashForm(shell, SWT.HORIZONTAL); createViewForm(sash, 1); createViewForm(sash, 2); createViewForm(sash, 3); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); } private void createViewForm(final SashForm sf, int index) { final ViewForm vf = new ViewForm(sf, SWT.BORDER); Text text = new Text(vf, SWT.MULTI | SWT.V_SCROLL); text.setText("Text" + index); CLabel titleLabel = new CLabel(vf, SWT.NONE); titleLabel.setText("ViewForm" + index); titleLabel.addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent e) { maximizeHelper(vf, sf); } }); vf.setTopLeft(titleLabel); vf.setContent(text); } private void maximizeHelper(Control c, SashForm sf) { if (sf.getMaximizedControl() == c) { sf.setMaximizedControl(null); } else { sf.setMaximizedControl(c); } } } 最新更新日: 2004年8月25日 |
- PR -
マイクロソフト お得な見積! まとめての購入ならオトクな方法で。ライセンスだから管理も簡単。 シマンテック 割引価格! オンライン販売だから低価格。いつでも簡単、見積・購入。 |
||||
|
|||||
Copyright(C) 2003,2004 Jasmin Project. All Right Reserved. |
SEO | [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送 | ||