Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 23

Download

Windows & dialogs

Can I just open up my own frames and dialogs?

  • Yes, you could; but please instead use the standard windowing system to do these sorts of things. Then you will properly handle docking, separated floating windows, context help, various keyboard shortcuts, and many other things contributing to the IDE’s appearance and functionality.

  • The Window System API describes the general steps you should use to open up new function windows, if you need such a thing. Specifically, you should use `TopComponent`s for such purposes.

  • You can also use DialogDisplayer.notify(NotifyDescriptor) to show dialogs that interact well with the IDE’s window system, and have a number of bits of prebuilt UI. You can use various standard subclasses of NotifyDescriptor to represent simple messages; exceptions; general-purpose dialogs with content panels; or even multi-stage wizards.

What are the steps to create a simple Wizard?

Easiest way is to use File → New File wizard, Module Development category and Wizard item, which will generate all needed boilerplate code for you. Essentially what wizard does is described below:

Create Panels:

You should start with creating a set (at least one) on WizardDescriptor.Panel objects (see Wizard Panel Performance Guide for more information about the best way to create a panel).

Create WizardDescriptor

Use the panels to tell the a WizardDescriptor instance the sequence of panels it should display. This you can do either directly by WizardDescriptor wd = WizardDescriptor(wizardPanelArray) Or you can create a WizardDescriptor.Iterator with these panels, which gives you more control over the sequencing.

Set Properties

Set certain properties on the WizardDescriptor which can influence the appearence of the wizard. If you like to add a help pane for example you call: wd.putProperty("WizardPanel_autoWizardStyle",Boolean.TRUE); wd.putProperty("WizardPanel_helpDisplayed",Boolean.TRUE);

This will display a help html file which has to be defined on each panel by setting a clientProperty in the JComponent superclass of the panel that is the wizard content. In this case it would look like:

putClientProperty("WizardPanel_helpURL",new URL("http://path/to/help/html/file/panelHelp.html"));

Show Wizard

Finally you set the Wizard to screen using the DialogDisplayer

Dialog d = DialogDisplayer.getDefault().createDialog(wd);

        d.setVisible(true);

        d.toFront();