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

Cannot get rid of OK and CANCEL buttons using pure FXML

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u45
    • Fix Version/s: 9
    • Component/s: javafx
    • Labels:
    • Subcomponent:

      Description

      An alert of type CONFIRMATION by default shows ButtonTypes OK and CANCEL. When providing other buttons type to the constructor using Java code, OK and CANCEL do not show up.

      When not using Java code, but instead declare the alert instance using FXML, the provision of ButtonTypes leads to the weird result of having both, the provided buttons AND the default buttons.

      For example:

        <Alert alertType="CONFIRMATION" >
          <buttonTypes>
            <ButtonType fx:constant="YES" />
            <ButtonType fx:constant="NO" />
          </buttonTypes>
        </Alert>

      The reasons is that the Alert constructor does not define "buttonTypes" as @NamedArgument, while setting the buttonTypes property does not clear existing buttons.

      There actually is no way in FXML to get rid of the default buttons!

      This is a very ugly flaw as either the designer has to modify the design (using OK / CANCEL instead of YES / NO), or he needs a Java programmer to change the controller's source code each time he wants to use a different ButtonType.

        Attachments

          Activity

            People

            Assignee:
            vadim Vadim Pakhnushev
            Reporter:
            mkarg Markus Karg
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: