資源描述:
《swt折疊式菜單制作》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、可折疊的SWT面板一個可折疊的SWT寫的面板,點擊面板能夠顯示出隱藏的控件,其中折疊區(qū)域的DataTime是日期時間控件,如果想正常顯示這個控件的效果,一定要把eclipse換成最新的eclipse3.3,我在官網(wǎng)上看到的最新版是eclipse3.3M6;SWT-Designer要用SWT-Designer6.0,只有這個版本的SWT-Designer才支持eclipse3.3里面的時間控件。我在eclipseSWT/Jface核心應用這本書里面看到,作者利用在rcp中利用eclipse表單實現(xiàn)了一個可折疊的面板
2、,書中也提到了SWT可以用eclipse表單,但是沒有具體的實現(xiàn)代碼,我利用書中內(nèi)容實現(xiàn)了一個在SWT中應用eclipse表單。下面是代碼:packagecom.lw.swt;8importorg.eclipse.swt.SWT;importorg.eclipse.swt.custom.StackLayout;importorg.eclipse.swt.layout.FillLayout;importorg.eclipse.swt.layout.FormAttachment;importorg.eclipse.s
3、wt.layout.FormData;importorg.eclipse.swt.layout.FormLayout;importorg.eclipse.swt.layout.GridData;importorg.eclipse.swt.layout.GridLayout;importorg.eclipse.swt.layout.RowLayout;importorg.eclipse.swt.layout.grouplayout.GroupLayout;importorg.eclipse.swt.layout.g
4、rouplayout.LayoutStyle;importorg.eclipse.swt.widgets.Button;importorg.eclipse.swt.widgets.Composite;importorg.eclipse.swt.widgets.DateTime;importorg.eclipse.swt.widgets.Display;importorg.eclipse.swt.widgets.Label;importorg.eclipse.swt.widgets.Shell;importorg.
5、eclipse.swt.widgets.Text;8importorg.eclipse.ui.forms.events.ExpansionAdapter;importorg.eclipse.ui.forms.events.ExpansionEvent;importorg.eclipse.ui.forms.widgets.ExpandableComposite;importorg.eclipse.ui.forms.widgets.FormToolkit;importorg.eclipse.ui.forms.widg
6、ets.ScrolledForm;importorg.eclipse.ui.forms.widgets.Section;importorg.eclipse.ui.forms.widgets.TableWrapLayout;publicclassNeTest{/***Launchtheapplication*@paramargs*/publicstaticvoidmain(String[]args){finalDisplaydisplay=Display.getDefault();finalShellshell=n
7、ewShell();shell.setSize(500,375);8shell.setText("SWTApplication");shell.setLayout(newFillLayout());//創(chuàng)建表單對象FormToolkitft=newFormToolkit(shell.getDisplay());//通過表單工具對象創(chuàng)建可滾動的表單對象finalScrolledFormform=ft.createScrolledForm(shell);//表單文本form.setText("swt表單example
8、");//設(shè)置表單布局form.getBody().setLayout(newTableWrapLayout());//創(chuàng)建可折疊的面板ExpandableCompositeec=ft.createExpandableComposite(form.getBody(),ExpandableComposite.TWISTIE);ec.setText("可折疊面板Expanda