简体   繁体   English

如何将Netbeans向导模块添加到自己的项目?

[英]How to add a Netbeans Wizard module to own project?

My question is simillar to topic: 我的问题与主题类似:
How to use netbeans module in my own project? 如何在自己的项目中使用netbeans模块?
but I have problem with invoking created wizard. 但是我在调​​用创建向导时遇到了问题。 I have copied wizard sources and libraries to my own project. 我已将向导源和库复制到我自己的项目中。
Now I want to call a wizard after clicking some button in my application (code for buttons action performed method below - it is generated by Netbeans): 现在,我想在应用程序中单击某些按钮后调用向导(按钮代码执行的方法如下-它是由Netbeans生成的):

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DemoWizardAction d = new DemoWizardAction(); d.actionPerformed(evt); }


So now, after button's click wizard's frame is invoked, but it disappears when I click "next" button (it should go to a second wizard's frame). 因此,现在,在调用按钮的单击向导的框架之后,但是当我单击“下一个”按钮时,它消失了(它应该转到第二个向导的框架)。
Could somebody help how to call wizard properly? 有人可以帮忙如何正确调用向导吗?

I also hat the problem that my wizard disappeared. 我也讨厌向导消失的问题。 This used to happen because the Trivial implementation of DialogDisplayer closes the dialog once a button is clicked. 之所以会发生这种情况,是因为DialogDisplayerTrivial实现会在单击按钮后关闭对话框。

My solution: Do not use the notify() method. 我的解决方案:不要使用notify()方法。

My code example: 我的代码示例:

public void actionPerformed(final ActionEvent e) {
  final List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
  panels.add(new WizardPanel());
  panels.add(new WizardPanel2());
  final String[] steps = new String[panels.size()];
  for (int i = 0; i < panels.size(); i++) {
    final Component c = panels.get(i).getComponent();
    // Default step name to component name of panel.
    steps[i] = c.getName();
    if (c instanceof JComponent) { // assume Swing components
      final JComponent jc = (JComponent) c;
      jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
      jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
      jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
      jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
      jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
      // jc.putClientProperty(WizardDescriptor.PROP_IMAGE,
      // ImageUtilities.loadImage("com/skytron/pvgw/icons/logo40.png", true));
      // jc.putClientProperty(WizardDescriptor.PROP_IMAGE_ALIGNMENT, "South");
    }
  }

  final WizardDescriptor wiz = new WizardDescriptor(
      new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
  // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
  wiz.setTitleFormat(new MessageFormat("{0}"));
  wiz.setTitle("...dialog title...");

  // this does not work outside of netbeans!!!
  // if (DialogDisplayer.getDefault().notify(wiz) ==
  // WizardDescriptor.FINISH_OPTION) {
  // do something
  // }

  // create a dialog and set it visible.
  final Dialog wizardDialog = DialogDisplayer.getDefault().createDialog(wiz);
  wizardDialog.setVisible(true);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM