The standard code used to display a dialog in NetBeans is:

DialogDescriptor dd = new DialogDescriptor(new UIPanel(), "UI Panel" ) ;
Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
dlg.setVisible(true);



This uses the DialogDescriptor and DialogDisplayer classes from the Dialogs API. You end up a dialog which looks like the image below.




However, what if you want to display some notification messages to the user? NotificationLineSupport to the rescue. Just create a notification line (code highlighted below) and add your message.

DialogDescriptor dd = new DialogDescriptor(new UIPanel(), "UI Panel" ) ;
NotificationLineSupport supp = dd.createNotificationLineSupport();
Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
supp.setInformationMessage("Sample Information Message" ) ;
dlg.setVisible(true);


The result is a dialog like the one shown below:





You can show informational messages, error messages and warning messages. However, displaying an error or a warning message does not disable the OK button. For that you will have to call the setValid() method.




More...