JFace组件Wizard小用(二)

  1,创建JFace组件wizard 主要用到了org.eclipse.jface.wizard.IWizard和org.eclipse.jface.wizard.IWizardPage,使用代码WizardDialog dialog = new WizardDialog(getShell(), wizard); dialog.setPageSize(-1,125); dialog.open(); 初始化wizard,其中wizard为继承wizard的子类,在wizard子类中通过public void addPages(){ pageOne = new WizardPageOne(); pageTwo = new WizardPageTwo(); addPage(pageOne); addPage(pageTwo); } 将WizardPage子类添加到Wizard中,即Wizard是JFrame,而WizardPage则是WizardPage。
  2,控制导航按钮
  实现canFlipToNextPage()来返回true,当用户输入完所有必须的数据且所有数据格式正确;
  重写canFinish()来指示想到是否可以完成. public Boolean canFlipToNextPage(){ if (getErrorMessage() != null) return false; if (isTextNonEmpty(fromText)&& isTextNonEmpty(toText) && (planeButton.getSelection() || carButton.getSelection()) && isReturnDateSet()) return true; return false; } 当添加组件例如Text等的listener之后可以在事件处理代码中使用getWizard().getContainer().updateButtons()来强制刷新导航按钮.
  3,控制WizardPage顺序
  WizardPage的顺序一般是按照addPage()的顺序显示,但是在实际使用中很有可能根据用户的输入来动态决定后续交互的页面,可以重写方法getNextPage() public IWizardPage getNextPage(){ if (planeButton.getSelection()) { PlanePage page = ((HolidayWizard)getWizar()).planePage; page.onEnterPage(); return page; } // Returns the next page depending on the selected button if (carButton.getSelection()) { return ((HolidayWizard)getWizard()).carPage; } return null; } 4,初始化WizardPage
  主要通过重写createControl(Composite parent)方法,定义容器Composite,然后通过setControl(composite)添加到wizardPage中
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值