Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123278

Regression: NPE when creating Swing-Components from JavaFX-Application

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7u25
    • Fix Version/s: 8
    • Component/s: deploy

      Description

      Starting with Java7 u25 our JavaFX-application crashes with a nullpointer exception, when creating Swing component:

      java.lang.NullPointerException
      at javax.swing.SwingUtilities.appContextGet(Unknown Source)
      at javax.swing.JComponent.getDefaultLocale(Unknown Source)
      at javax.swing.JComponent.<init>(Unknown Source)
      at javax.swing.text.JTextComponent.<init>(Unknown Source)
      at javax.swing.JEditorPane.<init>(Unknown Source)
      at javax.swing.JTextPane.<init>(Unknown Source)
      at com.infowerk.sample.Sample.applicationContextLoaded(Sample.java:77)
      at com.infowerk.sample.Sample.start(Sample.java:45)
      at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
      at java.lang.Thread.run(Unknown Source)

      Calling SwingUtilities.invokeLater does not help either. This causes the following exception:

      java.lang.NullPointerException
      at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
      at sun.awt.SunToolkit.getSystemEventQueueImplPP(Unknown Source)
      at sun.awt.SunToolkit.getSystemEventQueueImpl(Unknown Source)
      at java.awt.Toolkit.getEventQueue(Unknown Source)
      at java.awt.EventQueue.invokeLater(Unknown Source)
      at javax.swing.SwingUtilities.invokeLater(Unknown Source)
      at com.infowerk.sample.Sample.applicationContextLoaded(Sample.java:63)
      at com.infowerk.sample.Sample.start(Sample.java:45)
      at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
      at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
      at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
      at java.lang.Thread.run(Unknown Source)

      We created a small example application to show the problem.
      Go here http://editorv1.beta-wwp.infowerk.de/sample/fx-swing-sample.html to execute it. The exceptions will printed to the java console.
      The full sourcecode is attached to this issue.
      The exceptions only occur, when executing the code in a Webstart application. The code works fine, when started from within an IDE (eclipse) or when using Java Update 21 plugin.

      The live application (in german) can currently be found here.
      http://www.lidl-druckservice.de/briefpapier-din-a4.html
      Click the "Jetzt gestalten" (Design now) Button to launch our JavaFX Editor. On the main documents doubleclick any of the textboxes to open the texteditor.
      Enter some text and try to close the texteditor with ok. If you run on the application on java 7u25 the texteditor will not close, because the exception from above is triggered.
      An application log file can be found in the WWP subdirectory under your home directory.
      As JavaFX textprocessing is not quite usable in JavaFX 7, we create a Swing TextPane in the background to render the text on a JavaFX-Pane.

      Note however that we consider pulling the "Jetzt gestalten" button from the website, until the problem is solved.

        Attachments

          Activity

            People

            • Assignee:
              ngthomas Thomas Ng (Inactive)
              Reporter:
              sfuchsjfx Stefan Fuchs (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: