blob: 1097e7ef0cc24e77c44ffca0d3eaeb22ae8c07d3 [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqWindowsAndDialogs
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqWindowsAndDialogs
:description: Apache NetBeans wiki DevFaqWindowsAndDialogs
:toc: left
:toc-title:
:syntax: true
== 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 link:http://performance.netbeans.org/howto/dialogs/wizard-panels.html[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("link:http://path/to/help/html/file/panelHelp.html[http://path/to/help/html/file/panelHelp.html]"));`
==== Show Wizard
Finally you set the Wizard to screen using the `DialogDisplayer`
[source,java]
----
Dialog d = DialogDisplayer.getDefault().createDialog(wd);
d.setVisible(true);
d.toFront();
----
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqWindowsAndDialogs[http://wiki.netbeans.org/DevFaqWindowsAndDialogs] ,
that was last modified by NetBeans user Saubrecht
on 2009-12-07T10:43:35Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.