The use of NetBeans Dialog API for the NetBeans JavaFX PDF Viewer Plugin

Recently at IDR solutions we were busy working on adding new features to our NetBeans JavaFX PDF viewer plugin making it even cooler. After adding 3 menu options to our plugin we wanted to add a notification that will be displayed from NetBeans and not from the application itself. To do so we used Dialogs API that comes with the NetBeans platform, therefore in this article I will show you how we added NotifyDescriptor.Message Dialog API and the other Dialogs that you can use.

Dialogs API provides alternative to the use of JDialog or JOptionPane and they are generated from NetBeans and not from your application. They are easy to use and altered.

NotifyDescriptor are the most common dialogs of standard dialogs and here there are:

NotifyDescriptor.Message – displays dialog box containing the message.

NotifyDescriptor.Message

NotifyDescriptor.Message msg = new NotifyDescriptor.Message("This is a message ");
DialogDisplayer.getDefault().notify(msg);

 

NotifyDescriptor.InputLine – requesting input from the user.

NotifyDescriptor.InputLine

You have to type the text that will be displayed and the title.

NotifyDescriptor.InputLine msg = new NotifyDescriptor.InputLine("Password ","Password required");
DialogDisplayer.getDefault().notify(msg);

 

NotifyDescriptor.Confirmation – displays question for the user.

NotifyDescriptor.Confirmation

NotifyDescriptor.Confirmation msg = new NotifyDescriptor.Confirmation("Do you want to continue? ");
DialogDisplayer.getDefault().notify(msg);

 

NotifyDescriptor.Exception – informing user.

NotifyDescriptor.Exception

NotifyDescriptor msg = new NotifyDescriptor.Exception(new Exception("This is Exception"));
DialogDisplayer.getDefault().notify(msg);

 

Progress API

Apart from Dialogs API’s, NetBeans also offers Progress API that we often use in our applications which is very easy to implement. Below is how it is done:

Progress bar

ProgressHandle ph = ProgressHandleFactory.createSystemHandle("The Progress");
ph.start(100);

Remember to add a module dependency on Progress API:

Right click on your project > chose properties > select libraries from the left panel >click Add.  In the module dependency dialog, in the filter type: Progress API and click OK.

Hopfully you have found this information useful.

This post is part of our “NetBeans article Index” series. In these articles, we aim to explore NetBeans in different ways, from useful hint and tips, to our how-to’s, experiences and usage of the NetBeans IDE.

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (TwitterFacebook and Google+) or the Blog RSS.

Related Posts:

The following two tabs change content below.
Sylwia is a developer at IDR Solutions working on JavaFX Development and on the NetBeans JavaFX Plugin. She is very passionate about programming and aims to improve constantly.
Sylwia

About Sylwia Dorota Kedzia

Sylwia is a developer at IDR Solutions working on JavaFX Development and on the NetBeans JavaFX Plugin. She is very passionate about programming and aims to improve constantly.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>