Thursday April 26, 2007
Building a Login Screen for a NetBeans Platform Application (Part 1)
Since the resolution of issue 92570, it is possible to show a modal dialog after the appearance of an application's splash screen, but before the appearance of an application's main window. And what would one want to put there? A login screen, of course. With this enhancement, it is possible to integrate some level of authentication into your NetBeans Platform application.
The specific method in question here is DialogDisplayer.notifyLater, which can now also be called before the main window is opened. When called from ModuleInstall.restored, the modal dialog is opened and blocks the main window until the modal dialog is closed. So, to implement this, use the Module Installer wizard, which will create a class that extends ModuleInstall (and adds relevant entries in the project.xml file and manifest file). You get a skeleton restored method for free. Fill out the method as follows:
public void restored() {
NotifyDescriptor nd = new NotifyDescriptor.Message("Ok");
DialogDisplayer.getDefault().notifyLater(nd);
}
You will now get a simple modal dialog, after the splash screen, where you must click OK before the main window of the application can open. See further examples in the Javadoc for Class NotifyDescriptor.
However, you can also create your own JPanel and return that in the above code, instead of "Ok". So, here's my new code:
LoginForm form = new LoginForm();
public void restored() {
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(form,"Login");
DialogDisplayer.getDefault().notifyLater(nd);
}
And your LoginForm could be anything here. Mine looks like this:
It could be wired up to a database, with logic in the panel for verifying the password. So, the key to all of this is the fact that it is a modal dialog that appears after the splash screen and before the main window. Hurray!
Continue with part 2 of this series...
In other news. What?! Another new domain name in the NetBeans world? Yes. And it is... http://www.netbeans.tv/. Check it out! Hilarious adventures (e.g., "Today we’re discovering the hard way why Turkish beer is just not a morning’s best friend...") of two random American dudes from Prague delivering NetBeans IDE to some guy in Palestine who couldn't receive it by mail...
Apr 26 2007, 04:22:05 AM PDT Permalink
Posted by Roumen on April 26, 2007 at 06:24 AM PDT #
Posted by Emilian Bold on April 26, 2007 at 06:24 AM PDT #
Hi Emilian, yes, this will be part of 6.0. The LifecylceManager's exit method seems fine to use. About the NetBeans domains, www.netbeans.tv is not owned by someone randomly, but by NetBeans itself. About your question whether you'd have trademark issues if you created such domains yourself, I don't know, will try to find out.
Posted by Geertjan on April 27, 2007 at 04:43 AM PDT #
i have other/continue scenario:
after login, there are logout menu
if logout menu clicked,
than logout menu change become login menu
on this state (logout) only help/about and login menu that enable.
how to implement it?
Posted by Agus Suhartono on May 02, 2007 at 06:53 AM PDT #
Where can I find NotifyDescriptor in NetBeans 6.0 Beta 1 ?
Please send me an email.
Posted by Catalin Mincu on September 22, 2007 at 01:39 PM PDT #
Hi im new to netbeans and java I have started a
java desktop application (netbeans 6.5) love this article but how do i get past the first step Module Installer wizard I cant find this in the IDE or do you mean the plugins GUI under tools....
Thanks
Posted by Pete on July 30, 2008 at 01:37 PM PDT #
Pete, create a new module (not a Java desktop application which is what you seem to have but which has nothing to do with the NetBeans Platform), right-click it, choose New | Other and then in the New File dialog choose Module Development | Module Installer. (Then join the dev@openide.netbeans.org mailing list to join discussions and questions about the NetBeans Platform.)
Posted by Geertjan on July 30, 2008 at 04:14 PM PDT #
I created this module, but it run when i start netbeans.What can I do to add this login window to my application ?
Posted by rafaub on October 14, 2008 at 07:12 AM PDT #


