Displaying dialog during module restore causes java.lang.IllegalStateException: no splash screen available

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying dialog during module restore causes java.lang.IllegalStateException: no splash screen available

Martin Barnáš
Hi all,

I have application built on top of Netbeans Platform and I need to do some checks during loading of one of the modules and display a dialog if some of the check fails to let the user to decide what should happen.

Inspired by this tutorial https://platform.netbeans.org/tutorials/60/nbm-login.html I created installer for the module and put the checks and dialog display to the installers method restore().

public class Installer extends ModuleInstall {

    @Override
    public void restored() {
        if (check()) {
            DialogDisplayer.getDefault().notify(myDialogDescriptor);
            //...
        }
    }

This works but causes the splash screen to be closed and later there occurs an exception

java.lang.IllegalStateException: no splash screen available
at java.awt.SplashScreen.checkVisible(SplashScreen.java:197)
at java.awt.SplashScreen.update(SplashScreen.java:324)
at org.netbeans.core.startup.Splash$SplashPainter.repaint(Splash.java:401)
at org.netbeans.core.startup.Splash$SplashPainter$1.run(Splash.java:442)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

What can I do to prevent this exception?

Thanks
Martin

Reply | Threaded
Open this post in threaded view
|

Re: Displaying dialog during module restore causes java.lang.IllegalStateException: no splash screen available

paolo repele
Hi,
you have to wait the window manager is ready before to use dialog displayer.
Try

WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
                    @Override
                    public void run() {
                         //do something
                    }
});

On 16 October 2017 at 15:52, Martin Barnáš <[hidden email]> wrote:
Hi all,

I have application built on top of Netbeans Platform and I need to do some checks during loading of one of the modules and display a dialog if some of the check fails to let the user to decide what should happen.

Inspired by this tutorial https://platform.netbeans.org/tutorials/60/nbm-login.html I created installer for the module and put the checks and dialog display to the installers method restore().

NetBeans Platform Login Tutorial. This tutorial demonstrates how to create a login form for a NetBeans Platform application with very simple user and password management.
public class Installer extends ModuleInstall {

    @Override
    public void restored() {
        if (check()) {
            DialogDisplayer.getDefault().notify(myDialogDescriptor);
            //...
        }
    }

This works but causes the splash screen to be closed and later there occurs an exception

java.lang.IllegalStateException: no splash screen available
at java.awt.SplashScreen.checkVisible(SplashScreen.java:197)
at java.awt.SplashScreen.update(SplashScreen.java:324)
at org.netbeans.core.startup.Splash$SplashPainter.repaint(Splash.java:401)
at org.netbeans.core.startup.Splash$SplashPainter$1.run(Splash.java:442)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

What can I do to prevent this exception?

Thanks
Martin




--
Non hai veramente capito qualcosa fino a quando non sei in grado di spiegarlo a tua nonna. (A.Einstein)