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

Button with prefWidth="Infinity" in GridPane breaks the runtime

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7u45
    • javafx
    • OS: Win 7 [6.1.7601]
      Java: java version "1.7.0_45"
      Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
      Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

      I have created a GridPane with one row and two collumns. In each cell I have placed a Button. I wanted the buttons to fill the whole cell so I set prefWidth="Infinitiy". (I have learned that I should use maxWidth="Infinity" for that purpose but still I think this shouldnt break the runtime or at least give some kind of error message).

      Observed behavior when setting prefWidth="Infinity":

       - Scene Builder (1.1) instantly freezes when you set the property or if you try to open a file with this property set.
       - If the application with this FXML defined GUI is run no GUI appears and the process allocates huge amounts of heap (according to jvisualvm about 1,2GB/s for ArrayLists) that seem to get garbage collected instantly.


      Here is FXML to reproduce:
      <?xml version="1.0" encoding="UTF-8"?>

      <?import java.lang.*?>
      <?import java.net.*?>
      <?import java.util.*?>
      <?import javafx.geometry.*?>
      <?import javafx.scene.control.*?>
      <?import javafx.scene.image.*?>
      <?import javafx.scene.layout.*?>
      <?import javafx.scene.paint.*?>
      <?import javafx.scene.text.*?>


      <GridPane id="GridPane" alignment="TOP_LEFT" disable="false" gridLinesVisible="false" hgap="5.0">
          <children>
              <Button mnemonicParsing="false" prefWidth="Infinity" styleClass="add-button" text="Save" GridPane.columnIndex="0" GridPane.rowIndex="0" />
              <Button mnemonicParsing="false" text="Discard" GridPane.columnIndex="1" GridPane.rowIndex="0" />
          </children>
          <columnConstraints>
             <ColumnConstraints hgrow="SOMETIMES" />
             <ColumnConstraints hgrow="SOMETIMES" />
          </columnConstraints>
          <rowConstraints>
             <RowConstraints vgrow="SOMETIMES" />
          </rowConstraints>
      </GridPane>

            msladecek Martin Sládeček
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: