資源描述:
《swt折疊式菜單制作》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、可折疊的SWT面板一個(gè)可折疊的SWT寫(xiě)的面板,點(diǎn)擊面板能夠顯示出隱藏的控件,其中折疊區(qū)域的DataTime是日期時(shí)間控件,如果想正常顯示這個(gè)控件的效果,一定要把eclipse換成最新的eclipse3.3,我在官網(wǎng)上看到的最新版是eclipse3.3M6;SWT-Designer要用SWT-Designer6.0,只有這個(gè)版本的SWT-Designer才支持eclipse3.3里面的時(shí)間控件。我在eclipseSWT/Jface核心應(yīng)用這本書(shū)里面看到,作者利用在rcp中利用eclipse表單實(shí)現(xiàn)了一個(gè)可折疊的面板,
2、書(shū)中也提到了SWT可以用eclipse表單,但是沒(méi)有具體的實(shí)現(xiàn)代碼,我利用書(shū)中內(nèi)容實(shí)現(xiàn)了一個(gè)在SWT中應(yīng)用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.swt
3、.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.grou
4、playout.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.ecli
5、pse.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.widgets.S
6、crolledForm;importorg.eclipse.ui.forms.widgets.Section;importorg.eclipse.ui.forms.widgets.TableWrapLayout;publicclassNeTest{/***Launchtheapplication*@paramargs*/publicstaticvoidmain(String[]args){finalDisplaydisplay=Display.getDefault();finalShellshell=newShel
7、l();shell.setSize(500,375);8shell.setText("SWTApplication");shell.setLayout(newFillLayout());//創(chuàng)建表單對(duì)象FormToolkitft=newFormToolkit(shell.getDisplay());//通過(guò)表單工具對(duì)象創(chuàng)建可滾動(dòng)的表單對(duì)象finalScrolledFormform=ft.createScrolledForm(shell);//表單文本form.setText("swt表單example");//設(shè)置
8、表單布局form.getBody().setLayout(newTableWrapLayout());//創(chuàng)建可折疊的面板ExpandableCompositeec=ft.createExpandableComposite(form.getBody(),ExpandableComposite.TWISTIE);ec.setText("可折疊面板Expanda