| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <!-- -*- xhtml -*- --> |
| <title>适用于 NetBeans 平台 6.5 的 NetBeans 向导模块教程</title> |
| <link rel="stylesheet" type="text/css" href="https://netbeans.org/netbeans.css"> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <meta name="AUDIENCE" content="NBUSER"> |
| <meta name="TYPE" content="ARTICLE"> |
| <meta name="EXPIRES" content="N"> |
| <meta name="developer" content="geertjan.wielenga@sun.com"> |
| <meta name="indexed" content="y"> |
| <meta name="description" |
| content="A walk-through of the |
| basic features of the Wizard API classes."> |
| <!-- Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. --> |
| <!-- Use is subject to license terms.--> |
| </head> |
| |
| <body> |
| |
| <h1>NetBeans 向导模块教程</h1> |
| |
| <p>在本教程中,您将了解如何使用 <a href="http://bits.netbeans.org/dev/javadoc/org-openide-dialogs/org/openide/package-summary.html">NetBeans 对话框 API</a> 的向导类提供的主要功能。</p> |
| |
| <p><b>目录</b></p> |
| |
| <p><img src="../images/articles/69/netbeans-stamp7-8-9.png" class="stamp" width="114" height="114" alt="本页上的内容适用于 NetBeans IDE 6.5、6.7、6.8" title="本页上的内容适用于 NetBeans IDE 6.5、6.7、6.8" /></p> |
| |
| <ul class="toc"> |
| <li><a href="#set">创建模块项目</a> |
| <li><a href="#wiz">创建向导基础结构</a> |
| <li><a href="#action">注册向导操作类</a> |
| <li><a href="#design">设计向导内容</a> |
| <li><a href="#process">处理用户数据</a> |
| <li><a href="#validate">验证用户数据</a> |
| <li><a href="#persist">在重新启动时永久保留数据</a> |
| <li><a href="#brand">标记向导</a> |
| <li><a href="#further">深入阅读</a> |
| </ul> |
| |
| |
| <p class="tips"> 在 NetBeans 平台应用程序中,可以创建很多不同种类的向导。如果要创建在“新建项目”对话框中显示的向导,请参见<a href="https://platform.netbeans.org/tutorials/nbm-projectsamples.html">项目样例模块教程</a>。如果要创建在“新建文件”对话框中显示的向导,请参见<a href="http://platform.netbeans.org/tutorials/nbm-filetemplates.html">文件模板模块教程</a>。在本教程中,将创建一个在单击工具栏按钮时显示的常规向导。 |
| |
| |
| <p><b>要学习本教程,您需要具备下表中列出的软件和资源。</b></p> |
| |
| <table> |
| <tbody> |
| <tr> |
| <th class="tblheader" scope="col">软件或资源</th> |
| <th class="tblheader" scope="col">要求的版本</th> |
| </tr> |
| <tr> |
| <td class="tbltd1"><a href="https://netbeans.org/downloads/index.html">NetBeans IDE</a></td> |
| <td class="tbltd1">6.7 或更高版本</td> |
| </tr> |
| <tr> |
| <td class="tbltd1"><a href="http://java.sun.com/javase/downloads/index.jsp">Java Developer Kit (JDK)</a></td> |
| <td class="tbltd1">版本 6 或<br/>版本 5</td> |
| </tr> |
| </tbody> |
| </table> |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="set"></a>创建模块项目</h2> |
| |
| <p>我们首先使用“新建模块”项目向导。在向导完成后,我们将获得每个 NetBeans 模块所需的基本源结构以及一些缺省文件。 |
| |
| <ol> |
| <li>选择“文件”>“新建项目”(Ctrl+Shift+N)。在“类别”下选择“NetBeans 模块”。在“项目”下选择“模块”。单击“下一步”。</li> |
| <li>在“名称和位置”面板的“项目名称”字段中键入 <tt>DemoWizard</tt>。将项目位置更改为计算机上的任意目录。将“独立模块”选项和“设置为主项目”复选框保留为选中状态。单击“下一步”。</li> |
| <li>在“基本模块配置”面板的“代码名称基”中键入 <tt>org.demo.wizard</tt>。</li> |
| <li>选择“生成 XML 层”。保留本地化包和 XML 层文件的位置,以将其存储在名为 <tt>org/demo/wizard</tt> 的包中。单击“完成”。</li> |
| </ol> |
| |
| <p> IDE 将创建 <tt>DemoWizard</tt> 项目。此项目包含所有源代码和项目 meta 数据,例如项目的 Ant 生成脚本。此项目在 IDE 中打开。您可以在“项目”窗口 (Ctrl-1) 中查看其逻辑结构,在“文件”窗口 (Ctrl-2) 中查看其文件结构。</p> |
| |
| |
| <br /> |
| |
| <!-- ===================================================================================== --> |
| |
| <p><h2><a name="wiz"></a>创建向导基础结构</h2> |
| |
| <p>在此部分,我们使用“向导”向导在模块中添加向导桩模块。 |
| |
| <ol> |
| <li><p>在“项目”窗口中,右键单击 "DemoWizard" 项目节点,选择“新建”|“其他”,然后选择“模块开发”|“向导”:</p> |
| <p><img border="1" src="../images/tutorials/wizard/wizard-wizard.png"/> |
| <p>单击“下一步”。</p> |
| </li> |
| <li><p>在“向导类型”面板中,在“向导面板数”字段中键入 2,并将其他值保持不变:</p> |
| <p><img border="1" src="../images/tutorials/wizard/wizard-wizard-3.png"/> |
| <p>上述面板中的字段如下所示: |
| <ul> |
| <li><b>注册类型</b>。确定用户访问向导的位置。如果选择“定制”,“向导”向导将创建一个新的操作类,可用于打开并初始化向导。如果选择“新建文件”,“向导”向导将在模块的 <tt>layer.xml</tt> 文件中注册向导。 |
| <li><b>向导步骤顺序</b>。确定向导是否为线性的,或者向导用户能否跳过向导步骤,具体取决于先前在向导中选择的内容。线性向导是“静态的”(缺省设置);而具有可跳过步骤的向导需要定制迭代器类,这是在选择“动态”时创建的。 |
| <li><b>向导面板数</b>。确定将创建的向导面板数。对于每个向导步骤,将创建两个 Java 文件(视图和控制器)。 |
| </ul> |
| <p>单击“下一步”。</p> |
| </li> |
| <li><p>在“名称和位置”面板的“类名前缀”中键入 <tt>Demo</tt>,然后从“包”下拉列表中选择主包:</p> |
| <p><img border="1" src="../images/tutorials/wizard/wizard-wizard-4.png"/> |
| <p>单击“完成”。</p> |
| </li> |
| </ol> |
| |
| <p>在“项目”窗口中,您现在应看到如下内容: |
| <p><img border="1" src="../images/tutorials/wizard/projects-window.png"/> |
| |
| <p><h2><a name="action"></a>注册向导操作类</h2> |
| |
| <p>在此部分,我们将修改操作类,并在 <tt>layer.xml</tt> 文件中注册该类。 |
| |
| <ol> |
| <li>打开 <tt>DemoWizardAction.java</tt> 文件,然后将所有代码替换为以下内容: |
| |
| <pre class=examplecode> |
| package org.demo.wizard; |
| |
| import java.awt.Component; |
| import java.awt.Dialog; |
| import java.awt.event.ActionEvent; |
| import java.awt.event.ActionListener; |
| import java.text.MessageFormat; |
| import javax.swing.JComponent; |
| import org.openide.DialogDisplayer; |
| import org.openide.WizardDescriptor; |
| |
| public final class DemoWizardAction implements ActionListener { |
| |
| private WizardDescriptor.Panel[] panels; |
| |
| public void actionPerformed(ActionEvent e) { |
| WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels()); |
| // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName() |
| wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); |
| wizardDescriptor.setTitle("Your wizard dialog title here"); |
| Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); |
| dialog.setVisible(true); |
| dialog.toFront(); |
| boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; |
| if (!cancelled) { |
| // do something |
| } |
| } |
| |
| /** |
| * Initialize panels representing individual wizard's steps and sets |
| * various properties for them influencing wizard appearance. |
| */ |
| private WizardDescriptor.Panel[] getPanels() { |
| if (panels == null) { |
| panels = new WizardDescriptor.Panel[]{ |
| new DemoWizardPanel1(), |
| new DemoWizardPanel2() |
| }; |
| String[] steps = new String[panels.length]; |
| for (int i = 0; i < panels.length; i++) { |
| Component c = panels[i].getComponent(); |
| // Default step name to component name of panel. Mainly useful |
| // for getting the name of the target chooser to appear in the |
| // list of steps. |
| steps[i] = c.getName(); |
| if (c instanceof JComponent) { // assume Swing components |
| JComponent jc = (JComponent) c; |
| // Sets step number of a component |
| // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*: |
| jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i)); |
| // Sets steps names for a panel |
| jc.putClientProperty("WizardPanel_contentData", steps); |
| // Turn on subtitle creation on each step |
| jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); |
| // Show steps on the left side with the image on the background |
| jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE); |
| // Turn on numbering of all steps |
| jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE); |
| } |
| } |
| } |
| return panels; |
| } |
| |
| public String getName() { |
| return "Start Sample Wizard"; |
| } |
| |
| } |
| </pre> |
| |
| </li> |
| |
| <p class="tips"> 我们将使用与生成的内容相同的代码,所不同的是,我们将实现 <tt>ActionListener</tt> 而不是 <tt>CallableSystemAction</tt>。这样做是因为,<tt>ActionListener</tt> 是一个标准 JDK 类,而 <tt>CallableSystemAction</tt> 不是。从 NetBeans 平台 6.5 开始,我们可以改用标准 JDK 类,这种类使用更简便,并且需要的代码更少。 |
| |
| <li>在 <tt>layer.xml</tt> 文件中注册操作类,如下所示: |
| |
| <pre class=examplecode> |
| <filesystem> |
| <folder name="Actions"> |
| <folder name="File"> |
| <file name="org-demo-wizard-DemoWizardAction.instance"> |
| <attr name="delegate" newvalue="org.demo.wizard.DemoWizardAction"/> |
| <attr name="iconBase" stringvalue="org/demo/wizard/icon.png"/> |
| <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/> |
| <attr name="noIconInMenu" stringvalue="false"/> |
| </file> |
| </folder> |
| </folder> |
| <folder name="Toolbars"> |
| <folder name="File"> |
| <file name="org-demo-wizard-DemoWizardAction.shadow"> |
| <attr name="originalFile" stringvalue="Actions/File/org-demo-wizard-DemoWizardAction.instance"/> |
| <attr name="position" intvalue="0"/> |
| </file> |
| </folder> |
| </folder> |
| </filesystem> |
| </pre> |
| |
| <p class="tips"> "iconBase" 元素指向主包中名为 "icon.png" 的图像。可以使用您自己以该名称命名的图像,并确保该图像为 16x16 像素大小,或者使用以下图像:<img border="1" src="../images/tutorials/wizard/icon.png"/> |
| |
| <li>运行该模块。将启动应用程序,将会在 <tt>layer.xml</tt> 文件中指定的位置看到该工具栏按钮: |
| |
| <p><img border="1" src="../images/tutorials/wizard/result-1.png"/> |
| |
| <p>单击该按钮,将会显示向导: |
| <p><img border="1" src="../images/tutorials/wizard/result-2.png"/> |
| <p>单击“下一步”,将会发现最终面板中的“完成”按钮已启用: |
| <p><img border="1" src="../images/tutorials/wizard/result-3.png"/> |
| |
| </li> |
| |
| </ol> |
| |
| <p>现在,向导基础结构可以正常工作了,让我们添加一些内容。 |
| |
| <p><h2><a name="design"></a>设计向导内容</h2> |
| |
| <p>在此部分,我们将在向导中添加一些内容并定制其基本功能。 |
| |
| <ol> |
| <li><p>打开 <tt>DemoWizardAction.java</tt> 文件,将会发现您可以为向导设置各种不同的定制属性:</p> |
| <p><img border="1" src="../images/tutorials/wizard/wizard-tweaking.png"/></p> |
| <p>可以在<a href="http://ui.netbeans.org/docs/ui_apis/wide/index.html">此处</a>了解这些属性的相关信息。 |
| </li> |
| <li><p>在 <tt>DemoWizardAction.java</tt> 中,将 <tt>wizardDescriptor.setTitle</tt> 更改为以下内容: |
| <pre class=examplecode> |
| wizardDescriptor.setTitle("Music Selection"); |
| </pre> |
| <li><p>打开 <tt>DemoVisualPanel1.java</tt> 和 <tt>DemoVisualPanel2.java</tt> 文件,并使用 "Matisse" GUI 生成器添加一些 Swing 组件,如下所示:</p> |
| <p><img border="1" src="../images/tutorials/wizard/panel-1-design.png"/></p> |
| <p><img border="1" src="../images/tutorials/wizard/panel-2-design.png"/></p> |
| <p>从上面可以看到 <tt>DemoVisualPanel1.java</tt> 和 <tt>DemoVisualPanel2.java</tt> 文件以及一些 Swing 组件。 |
| </li> |
| <li>在“源”视图中打开这两个面板,然后将其 <tt>getName()</tt> 方法分别更改为 "Name and Address" 和 "Musician Details"。 |
| <li><p>再次运行该模块。在打开向导时,将会看到如下内容,具体取决于添加的 Swing 组件和提供的定制内容:</p> |
| <p><img border="1" src="../images/tutorials/wizard/result-4.png"/></p> |
| |
| <p class="tips"> 上面向导左侧边栏中的图像是在 <tt>DemoWizardAction.java</tt> 文件中设置的,如下所示: |
| |
| <pre class=examplecode> |
| wizardDescriptor.putProperty("WizardPanel_image", ImageUtilities.loadImage("org/demo/wizard/banner.png", true)); |
| </pre> |
| |
| </ol> |
| |
| <p>现在,您已设计了向导内容,让我们添加一些代码以处理用户将输入的数据。 |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="process"></a>处理用户数据</h2> |
| |
| <p>在此部分,您将了解如何在面板之间传递用户数据,以及在单击“完成”后如何向用户显示结果。 |
| |
| <ol> |
| <li><p>在 <tt>WizardPanel</tt> 类中,使用 <tt>storeSettings</tt> 方法检索可视面板中的数据集。例如,在 <tt>DemoVisualPanel1.java</tt> 文件中创建 getter,然后从 <tt>DemoWizardPanel1.java</tt> 文件中访问它们,如下所示:</p> |
| |
| <pre class=examplecode> |
| public void storeSettings(Object settings) { |
| ((WizardDescriptor) settings).putProperty("name", ((DemoVisualPanel1)getComponent()).getNameField()); |
| ((WizardDescriptor) settings).putProperty("address", ((DemoVisualPanel1)getComponent()).getAddressField()); |
| } |
| </pre> |
| |
| </li> |
| <li><p>接下来,使用 <tt>DemoWizardAction.java</tt> 文件检索已设置的属性,并使用这些属性执行一些操作:</p> |
| |
| <pre class=examplecode> |
| public void actionPerformed(ActionEvent e) { |
| WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels()); |
| // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName() |
| wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); |
| wizardDescriptor.setTitle("Music Selection"); |
| Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor); |
| dialog.setVisible(true); |
| dialog.toFront(); |
| boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION; |
| if (!cancelled) { |
| <b>String name = (String) wizardDescriptor.getProperty("name"); |
| String address = (String) wizardDescriptor.getProperty("address"); |
| DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(name + " " + address));</b> |
| } |
| } |
| </pre> |
| |
| <p class="tips"> 也可以按其他方式使用 <tt>NotifyDescriptor</tt>,如代码完成框所示: |
| |
| <p><img border="1" src="../images/tutorials/wizard/notifydescriptor.png"/></p> |
| |
| |
| </ol> |
| |
| <p>现在,您已知道如何处理用户输入的数据了。 |
| |
| <br /> |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="validate"></a>验证用户数据</h2> |
| |
| <p>在此部分,您将了解在向导中单击“下一步”后如何验证用户输入的内容。 |
| |
| <ol> |
| <li><p>在 <tt>DemoWizardPanel1</tt> 中,更改类签名以实现 <tt>WizardDescriptor.ValidatingPanel</tt> 而不是 <tt>WizardDescriptor.Panel</tt>:</p> |
| |
| <pre class=examplecode> |
| public class DemoWizardPanel1 implements WizardDescriptor.ValidatingPanel |
| </pre> |
| |
| <li>在类顶部,将 <tt>JComponent</tt> 声明更改为带类型的声明: |
| |
| <pre class=examplecode> |
| private DemoVisualPanel1 component; |
| </pre> |
| |
| <li>实现所需的抽象方法,如下所示: |
| |
| <pre class=examplecode> |
| @Override |
| public void validate() throws WizardValidationException { |
| |
| String name = component.getNameTextField().getText(); |
| if (name.equals("")){ |
| throw new WizardValidationException(null, "Invalid Name", null); |
| } |
| |
| } |
| </pre> |
| |
| <li><p>运行该模块。单击“下一步”,无需在“名称”字段中输入任何内容,将会看到以下结果。另外,还会发现由于验证失败而无法移到下一面板:</p> |
| |
| <p><img border="1" src="../images/tutorials/wizard/validation1.png"/></p> |
| |
| <li>(可选)在名称字段为空时禁用“下一步”按钮。首先,在类顶部声明一个布尔值: |
| |
| <pre class=examplecode> |
| private boolean isValid = true; |
| </pre> |
| |
| <p>然后覆盖 <tt>isValid()</tt>,如下所示: |
| |
| <pre class=examplecode> |
| @Override |
| public boolean isValid() { |
| return isValid; |
| } |
| </pre> |
| |
| <p>在调用 <tt>validate()</tt> 时(单击“下一步”按钮时调用),将返回 false: |
| |
| <pre class=examplecode> |
| @Override |
| public void validate() throws WizardValidationException { |
| |
| String name = component.getNameTextField().getText(); |
| if (name.equals("")) { |
| <b>isValid = false;</b> |
| throw new WizardValidationException(null, "Invalid Name", null); |
| } |
| |
| } |
| </pre> |
| |
| <p>或者,也可以最初将布尔值设置为 false。然后实现 <tt>DocumentListener</tt>,在字段上添加一个侦听程序;当用户在字段中键入某些内容时,将布尔值设置为 true 并调用 <tt>isValid()</tt>。 |
| </ol> |
| |
| <p>现在,您已知道如何验证用户输入的数据了。 |
| |
| <p class="tips"> 有关验证用户输入的详细信息,请参见本教程结尾的 Tom Wheeler 样例。 |
| |
| <br /> |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="persist"></a>在重新启动时永久保留数据</h2> |
| |
| <p>在此部分,您将了解如何在关闭应用程序时存储数据,以及在重新启动后打开向导时如何检索数据。 |
| |
| <ol> |
| |
| <li><p>在 <tt>DemoWizardPanel1.java</tt> 中覆盖 <tt>readSettings</tt> 和 <tt>storeSettings</tt> 方法,如下所示:</p> |
| |
| <pre class=examplecode> |
| <b>JTextField nameField = ((DemoVisualPanel1) getComponent()).getNameTextField(); |
| JTextField addressField = ((DemoVisualPanel1) getComponent()).getAddressTextField();</b> |
| |
| @Override |
| public void readSettings(Object settings) { |
| <b>nameField.setText(NbPreferences.forModule(DemoWizardPanel1.class).get("namePreference", "")); |
| addressField.setText(NbPreferences.forModule(DemoWizardPanel1.class).get("addressPreference", ""));</b> |
| } |
| |
| @Override |
| public void storeSettings(Object settings) { |
| ((WizardDescriptor) settings).putProperty("name", nameField.getText()); |
| ((WizardDescriptor) settings).putProperty("address", addressField.getText()); |
| <b>NbPreferences.forModule(DemoWizardPanel1.class).put("namePreference", nameField.getText()); |
| NbPreferences.forModule(DemoWizardPanel1.class).put("addressPreference", addressField.getText());</b> |
| } |
| </pre> |
| |
| </li> |
| |
| <li><p>再次运行该模块,然后在向导的第一个面板中键入名称和地址:</p> |
| <p><img border="1" src="../images/tutorials/wizard/nbpref1.png"/></p> |
| </li> |
| |
| <li><p>关闭应用程序,打开“文件”窗口,然后查看应用程序的 <tt>build</tt> 文件夹中的属性文件。现在,将会找到如下设置:</p> |
| <p><img border="1" src="../images/tutorials/wizard/nbpref2.png"/></p> |
| </li> |
| |
| <li><p>再次运行应用程序,然后在打开向导时,将自动使用上面指定的设置定义向导字段中的值。</p> |
| </li> |
| |
| </ol> |
| |
| <p>现在,您已知道如何在重新启动时永久保留向导数据了。 |
| |
| <br /> |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="brand"></a>标记向导</h2> |
| |
| <p>在此部分,我们将“下一步”按钮的字符串(由向导基础结构提供)标记为 "Advance"。 |
| |
| <p class="tips"> 术语“标记”表示定制(即,通常指在同一语言中进行少量修改),而“国际化”或“本地化”表示翻译为其他语言。有关 NetBeans 模块本地化的信息,请<a href="http://translatedfiles.netbeans.org/index-l10n.html">转至此处</a>。 |
| |
| <ol> |
| <li><p>在“文件”窗口中,展开应用程序的 <tt>branding</tt> 文件夹,然后创建下面突出显示的文件夹/文件结构:</p> |
| |
| <p><img border="1" src="../images/tutorials/wizard/branding-1.png"/></p> |
| |
| </li> |
| <li>定义文件内容,如下所示: |
| |
| <pre class=examplecode> |
| CTL_NEXT=&Advance > |
| </pre> |
| |
| <p>您可能要标记的其他字符串如下所示: |
| |
| <pre class=examplecode> |
| CTL_CANCEL |
| CTL_PREVIOUS |
| CTL_FINISH |
| CTL_ContentName |
| </pre> |
| |
| <p class="tips"> 缺省情况下,将 "CTL_ContentName" 关键字设置为 "Steps";如果 "WizardPanel_autoWizardStyle" 属性未设置为 "FALSE",则会在向导左面板中使用该关键字。 |
| |
| |
| </li> |
| <li><p>运行应用程序,“下一步”按钮将标记为 "Advance":</p> |
| |
| <p><img border="1" src="../images/tutorials/wizard/branding-2.png"/></p> |
| |
| |
| |
| <p class="tips"> (可选)使用 <tt>DemoWizardAction.java</tt> 文件(如上所述)删除向导的整个左侧部分,如下所示: |
| |
| </p><pre class="examplecode"> wizardDescriptor.putProperty("WizardPanel_autoWizardStyle", Boolean.FALSE); |
| </pre> |
| |
| <p>上述设置将导致向导如下所示:</p> |
| |
| <p><img border="1" src="../images/tutorials/wizard/branding-3.png"/></p> |
| |
| </ol> |
| |
| <p>现在,您已知道如何将向导基础结构中定义的字符串标记为您自己的标记版本了。 |
| |
| <br /> |
| |
| <!-- ===================================================================================== --> |
| |
| <h2 class="tutorial"><a name="further"></a>深入阅读</h2> |
| |
| <p>我们在线提供了一些相关信息: |
| |
| <ul> |
| <li><p>Tom Wheeler 的 NetBeans 站点(单击下面的图像):</p> |
| <p><a href="http://www.tomwheeler.com/netbeans/"><img border="1" src="../images/tutorials/wizard/tom.png"/></a></p> |
| |
| <p class="tips"> 虽然是为 NetBeans 5.5 编写的,但已成功在带有 JDK 1.6 的 Ubuntu Linux 上针对 NetBeans IDE 6.5.1 测试了上述样例。 |
| |
| <p>该样例在说明如何验证用户数据方面尤其有用。 |
| |
| <li>Geertjan 的博客: |
| <ul> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/how_wizards_work">向导工作方式:第 1 部分 - 简介</a> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/how_wizards_work_part_2">向导工作方式:第 2 部分 - 各种类型</a> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/how_wizards_work_part_3">向导工作方式:第 3 部分 - 第一个向导</a> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/how_wizards_work_part_4">向导工作方式:第 4 部分 - 您自己的迭代器</a> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/how_wizards_work_part_5">向导工作方式:第 5 部分 - 重新使用和嵌入现有面板</a> |
| <li><a href="http://blogs.oracle.com/geertjan/entry/creating_a_better_java_class">创建更好的 Java 类向导</a> |
| </ul> |
| |
| </ul> |
| |
| <br /> |
| |
| |
| |
| <h2><a name="version"></a>版本控制 </h2> |
| |
| <p> |
| |
| <table width="76%" border="1"> |
| <tbody> |
| <tr> |
| <td> |
| <div align="left"><b>版本</b></div> |
| </td> |
| <td> |
| <div align="left"><b>日期</b></div> |
| </td> |
| <td> |
| <div align="left"><b>更改</b></div> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| 1 |
| </td> |
| <td> |
| 2009 年 3 月 31 日 |
| </td> |
| <td> |
| 初始版本。待更改项: |
| |
| <p><ul> |
| <li><strike>添加了有关验证用户输入的部分。</strike> |
| <li><strike>添加了有关在向导中存储/检索数据的部分。</strike> |
| <li>添加了一个表以列出所有 WizardDescriptor 属性。 |
| <li>添加了一个表以列出并说明所有向导 API 类。 |
| <li>添加了指向 Javadoc 的链接。 |
| </ul> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| 2 |
| </td> |
| <td> |
| 2009 年 4 月 1 日 |
| </td> |
| <td> |
| 添加了一个验证部分,其中包括用于禁用“下一步”按钮的代码。另外,还添加了持久性部分。 |
| </td> |
| </tr> |
| <tr> |
| <td> |
| 3 |
| </td> |
| <td> |
| 2009 年 4 月 10 日 |
| </td> |
| <td> |
| 整合了 Tom Wheeler 提供的注释,重新编写了标记部分,以便实际讲述标记内容,并引用了可以找到本地化信息的位置。 |
| </td> |
| </tr> |
| |
| </tbody> |
| </table> |
| |
| </body> |
| |
| </html> |