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

NullPointerException when label.setFont(null) is called

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u66
    • Fix Version/s: tbd
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_66"
      Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
      Java HotSpot(TM) Client VM (build 25.66-b17, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 x64

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      not relevant

      A DESCRIPTION OF THE PROBLEM :
      When trying to reset the font to its default value with null for Label, a NullPointerException is thrown.

      When using the same code, but for a TextField, this works perfectly as expected.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      package com.ita;

      import javafx.application.Application;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Label;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class FontLoad extends Application
      {

          @Override
          public void start(Stage primaryStage)
              throws Exception
          {
              Label label = new Label("JavaFX Application");
              label.setFont(null);
              Button button = new Button("My Button");
              VBox box = new VBox(15, label, button);
              box.setAlignment(Pos.CENTER);
              Scene scene = new Scene(box, 500, 300);

              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args)
          {
              launch(args);
          }
      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected to have a Label with the text "JavaFX Application" displayed with the default font.
      ACTUAL -
      InvocationTargetException is thrown due to a NullPointerException

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Exception in Application start method
      java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
      at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
      Caused by: java.lang.RuntimeException: Exception in Application start method
      at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.NullPointerException
      at com.sun.javafx.scene.control.skin.Utils.computeTextHeight(Utils.java:129)
      at com.sun.javafx.scene.control.skin.LabeledSkinBase.computeMinLabeledPartHeight(LabeledSkinBase.java:707)
      at com.sun.javafx.scene.control.skin.LabeledSkinBase.computeMinHeight(LabeledSkinBase.java:689)
      at javafx.scene.control.Control.computeMinHeight(Control.java:487)
      at javafx.scene.Parent.minHeight(Parent.java:949)
      at javafx.scene.layout.Region.minHeight(Region.java:1401)
      at javafx.scene.layout.Region.computeChildPrefAreaHeight(Region.java:1762)
      at javafx.scene.layout.VBox.getAreaHeights(VBox.java:440)
      at javafx.scene.layout.VBox.layoutChildren(VBox.java:555)
      at javafx.scene.Parent.layout(Parent.java:1079)
      at javafx.scene.Scene.doLayoutPass(Scene.java:552)
      at javafx.scene.Scene.preferredSize(Scene.java:1646)
      at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)
      at javafx.stage.Window$9.invalidated(Window.java:846)
      at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
      at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
      at javafx.stage.Window.setShowing(Window.java:922)
      at javafx.stage.Window.show(Window.java:937)
      at javafx.stage.Stage.show(Stage.java:259)
      at com.ita.FontLoad.start(FontLoad.java:28)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
      at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
      at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
      at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
      ... 1 more
      Exception running application com.ita.FontLoad
      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: