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

Default button works on Mac runtime, not on Windows, when same button is assigned default & cancel.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8
    • fx2.0.2
    • javafx
    • No specifics known for user/developer Windows environment, but reproduced on my Win 7 laptop w/JDK7u7 and JDK7u9.

      Using DialogFX lib directly or w/i JFXtras, designate same button as default & cancel (example use case: prompting user to delete something, want to default in all cases to "No" button). Calls to setDefaultButton() & setCancelButton() work, code executes fine on Mac (ENTER & ESCAPE both return value for designated button), but not on Windows. Tested on at least two Windows machines with same results.

      Some sample code to setup dialog is:

              List<String> buttonLabels = new ArrayList<>(2);
              buttonLabels.add("Affirmative");
              buttonLabels.add("Negative");
              
              DialogFX dialog = new DialogFX(Type.QUESTION);
              dialog.setTitleText("Question Dialog Box Example");
              dialog.setMessage("This is an example of an QUESTION dialog box, created using DialogFX. This also demonstrates the automatic wrapping of text in DialogFX. Would you like to continue?");
              dialog.addButtons(buttonLabels, 1, 1);
              int i = dialog.showDialog();
              System.out.println("Return code=" + i);

      DialogFX.java attached, also available via GitHub.

            miflemi Mick Fleming
            mheckler Mark Heckler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: