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

Button types of a DialogPane are set twice, returns a wrong button

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        Windows 10
        Jdk-11.0.2 with newest JavaFX sources
        Jdk1.8.0_241

        A DESCRIPTION OF THE PROBLEM :
        When the button types of a DialogPane are set twice, DialogPane#lookupButton does return a wrong button.

        This is due DialogPane adding two list change listeners to 'buttons' (#getButtonTypes). They have the wrong order, which will result in the button bar not changing at all, but the buttonNodes list will have a new button added to it, which will not be displayed.

        I will file a PR showing (via testcase) and fixing the described bug.


        ---------- BEGIN SOURCE ----------
        public class Test extends Application {

            @Override
            public void start(Stage primaryStage) {
                Scene scene = new Scene(new BorderPane());
                primaryStage.setScene(scene);

                primaryStage.show();

                Dialog dialog = new Dialog();
                dialog.getDialogPane().getButtonTypes().setAll(ButtonType.OK);
                dialog.getDialogPane().getButtonTypes().setAll(ButtonType.OK);

                Button node = (Button) dialog.getDialogPane().lookupButton(ButtonType.OK);
                node.setText("TEST");

                dialog.showAndWait();
                // The OK button won't show 'TEST'
            }

        }
        ---------- END SOURCE ----------

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                aghaisas Ajit Ghaisas
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: