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

NullPointerException in DatePicker when a custom ButtonSkin is set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u45
    • javafx
    • None
    • Windows 7, Java 1.8.0_45

        When using a custom button skin together with the DatePicker's calendar button one get's multiple NullPointerExceptions. SSCCE bellow.

        REC76.java:

        package rec.pkg76;

        import java.net.URL;
        import javafx.application.Application;
        import javafx.scene.Scene;
        import javafx.scene.control.DatePicker;
        import javafx.scene.layout.StackPane;
        import javafx.stage.Stage;

        public class REC76 extends Application {

            @Override
            public void start(Stage primaryStage) {

                StackPane root = new StackPane();

                DatePicker datePicker = new DatePicker();
                root.getChildren().add(datePicker);

                Scene scene = new Scene(root, 300, 250);

                URL styleSheet = REC76.class.getResource("stylesheet.css");
                scene.getStylesheets().add(styleSheet.toExternalForm());

                primaryStage.setTitle("Hello World!");
                primaryStage.setScene(scene);

                primaryStage.show();
            }

            /**
             * @param args the command line arguments
             */
            public static void main(String[] args) {
                launch(args);
            }

        }


        ButtonSkin.java:

        package rec.pkg76;

        import javafx.scene.control.Button;

        public class ButtonSkin extends com.sun.javafx.scene.control.skin.ButtonSkin {

            public ButtonSkin(Button button) {
                super(button);
                // NullPointerExecption even if the button skin doesn't do anything
            }

        }


        stylesheet.css:

        .button {
            -fx-skin: "rec.pkg76.ButtonSkin";
        }

              jgiles Jonathan Giles
              kacperjfx Kacper (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported: