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

NPE in PopupWindow.show if owner Window has no Scene

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • 8
    • javafx
    • None

      @Override public void start(Stage stage) throws IOException {

          Popup popup = new Popup();
          popup.show(stage, 0, 0);

      }

      Caused by: java.lang.NullPointerException
      at javafx.stage.PopupWindow.showImpl(PopupWindow.java:435)
      at javafx.stage.PopupWindow.show(PopupWindow.java:414)


      Fix is

      diff -r ee2deaadbc15 modules/graphics/src/main/java/javafx/stage/PopupWindow.java
      --- a/modules/graphics/src/main/java/javafx/stage/PopupWindow.java Wed Oct 30 21:47:34 2013 -0400
      +++ b/modules/graphics/src/main/java/javafx/stage/PopupWindow.java Thu Oct 31 08:36:54 2013 -0400
      @@ -432,8 +432,10 @@
               
               // RT-28447
               final Scene ownerScene = getRootWindow(owner).getScene();
      - sceneValue.getStylesheets().setAll(ownerScene.getStylesheets());
      -
      + if (ownerScene != null) {
      + sceneValue.getStylesheets().setAll(ownerScene.getStylesheets());
      + }
      +
               // It is required that the root window exist and be visible to show the popup.
               if (getRootWindow(owner).isShowing()) {
                   // We do show() first so that the width and height of the

            dgrieve David Grieve
            dgrieve David Grieve
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: