Problems in migrating Java 17 from Java 8 with X2Go terminal mode

392 views Asked by At

I'm trying to migrate to Java 17 from Java 8 over X2Go client and when I try to run a simple code that includes GUI, even dialog with 1 button, this exception is thrown:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "sun.awt.X11.XBaseWindow.isVisible()" because "parent" is null
            at java.desktop/sun.awt.X11.XWindowPeer.setToplevelTransientFor(XWindowPeer.java:1688)
            at java.desktop/sun.awt.X11.XWindowPeer.postInit(XWindowPeer.java:253)
            at java.desktop/sun.awt.X11.XDecoratedPeer.postInit(XDecoratedPeer.java:105)
            at java.desktop/sun.awt.X11.XBaseWindow.init(XBaseWindow.java:184)
            at java.desktop/sun.awt.X11.XBaseWindow.<init>(XBaseWindow.java:259)
            at java.desktop/sun.awt.X11.XWindow.<init>(XWindow.java:147)
            at java.desktop/sun.awt.X11.XComponentPeer.<init>(XComponentPeer.java:111)
            at java.desktop/sun.awt.X11.XCanvasPeer.<init>(XCanvasPeer.java:42)
            at java.desktop/sun.awt.X11.XPanelPeer.<init>(XPanelPeer.java:48)
            at java.desktop/sun.awt.X11.XWindowPeer.<init>(XWindowPeer.java:134)
            at java.desktop/sun.awt.X11.XDecoratedPeer.<init>(XDecoratedPeer.java:62)
            at java.desktop/sun.awt.X11.XDialogPeer.<init>(XDialogPeer.java:40)
            at java.desktop/sun.awt.X11.XToolkit.createDialog(XToolkit.java:1084)
            at java.desktop/java.awt.Dialog.addNotify(Dialog.java:768)
            at java.desktop/java.awt.Window.pack(Window.java:829)

I had no such problems in Java 8 and I couldn't find any hint that could solve this.

It doesn't occur when running in KDE mode only when the session is in single application mode. The OP is centOS 7.8.

Thanks in advance.

EDIT: As described in the Java-doc of JDialog: To create an unowned JDialog you must use either the JDialog(Window) or JDialog(Dialog) constructor with an argument of null.

This solves dialogs that are visible before the main frame. (i.e splash screen, password request etc.)

EDIT 2: For JOptionPane, calling to JOptionPane#setRootFrame(main_program) will prevent the exception and will provide the given parent.

This solves JOptionPane in case there is already opened Window visible.

0

There are 0 answers