当前页面: 开发资料首页 → Eclipse 专题 → Eclipse Forms设计漂亮UI之高级组件
摘要: Eclipse Forms提供了4个高级组件,这样你能够构建漂亮的UI
ExpandableComposite ec = toolkit.createExpandableComposi这个composite接受一些风格参数来控制它的表现行为te(form.getBody(), ExpandableComposite.TREE_NODE| ExpandableComposite.CLIENT _INDENT); ec.setText("Expandable Composite title"); String ctext = "We will now create a somewhat long text so that "+ "we can use it as content for the expandable composite. "+ "Expandable composite is used to hide or show the text using the " "toggle control"; Label client = toolkit.createLabel(ec, ctext, SWT.WRAP); ec.setClient(client); td = new TableWrapData(); td.colspan = 2; ec.setLayoutData(td); ec.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(Expansion Event e) { form.reflow(true); } });
Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION|Section这次我们用了TWISTIE风格,添加了描述并要求有标题栏.这个视图看起来应该象这样:.TITLE_BAR| Section.TWISTIE|Section .EXPANDED); td = new TableWrapData(TableWrapData.FILL); td.colspan = 2; section.setLayoutData(td); section.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(Expansion Event e) { form.reflow(true); } }); section.setText("Section title"); section.setDescription("This is the description that goes "+ below the title"); Composite sectionClient = toolkit.createComposite(section); sectionClient.setLayout(new GridLayout()); button = toolkit.createButton(sectionClient, "Radio 1", SWT.RADIO); button = toolkit.createButton(sectionClient, "Radio 2", SWT.RADIO); section.setClient(sectionClient);