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

Null pointer when a button without a mnemonic is re-added to a scene and alt is pressed


    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      Java 8u20 b11 Linux


      I believe the fix for bug RT-36336 introduced this null pointer exception. It looks like LabeledSkinBase now always responds to a new scene by adding a mnemonic even if it doesn't have one.

      Run the following test class:

      1. Press alt to see mnemonics set on the checkbox but not on the button.

      2. Uncheck the checkbox which will remove the button. Press alt again and everything is fine.

      3. Re-check the checkbox to add the button back. Press alt a third time and the null pointer exception will be thrown.

      ***************************************** Test Class ***********************************************************
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.geometry.Pos;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.CheckBox;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Region;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;

      public class MnemonicsTest extends Application {

         @Override public void start(final Stage primaryStage) throws Exception {

            final CheckBox button1 = new CheckBox("_Test with Mnemonic");
            final Button button2 = new Button("Test without Mnemonic");
            final HBox box = new HBox(20, button1, button2);
            box.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
            primaryStage.setScene(new Scene(new StackPane(box)));
            button1.setOnAction(new EventHandler<ActionEvent>() {
               @Override public void handle(ActionEvent event) {
                  if ( button1.isSelected() && !box.getChildren().contains(button2)) {
                  } else {



         public static void main(String[] args) throws Exception {





            • Assignee:
              msladecek Martin Sládeček
              csmithjfx Charles Smith (Inactive)
            • Votes:
              0 Vote for this issue
              4 Start watching this issue


              • Created: