Skip to content

Commit

Permalink
javaFxPart4.md: Stop auto-truncating chat text
Browse files Browse the repository at this point in the history
JiaXinEu authored Jul 26, 2024
1 parent 40c1323 commit 1729ebe
Showing 3 changed files with 12 additions and 1 deletion.
Binary file added tutorials/images/javafx/NoOverrunDialogBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/images/javafx/OverrunDialogBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion tutorials/javaFxPart4.md
Original file line number Diff line number Diff line change
@@ -81,14 +81,25 @@ Note that if you are using packages, `fx:controller="MainWindow"` needs to be up

<fx:root alignment="TOP_RIGHT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="400.0" type="javafx.scene.layout.HBox" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Label fx:id="dialog" text="Label" wrapText="true" />
<Label fx:id="dialog" text="Label" wrapText="true" minHeight="-Infinity"/>
<ImageView fx:id="displayPicture" fitHeight="99.0" fitWidth="99.0" pickOnBounds="true" preserveRatio="true" />
</children>
<padding>
<Insets bottom="15.0" left="5.0" right="5.0" top="15.0" />
</padding>
</fx:root>
```
<box type="info" seamless>

Note that for `Label`, we set `wrapText` to **true** and `minHeight` to **-Infinity**. This configuration wraps the text within the label, removes the minimum height constraint, and allows the label to grow vertically as needed.

![Set minHeight for Label](images/javafx/NoOverrunDialogBox.png)

Without setting `minHeight` to **-Infinity**, text overrun may occur when the text to be displayed exceeds the size of the label, causing the text to not be fully displayed and ending with `...` instead.

![No minHeight for Label](images/javafx/OverrunDialogBox.png)

</box>

1. Let’s explore the provided FXML files in Scene Builder.

0 comments on commit 1729ebe

Please sign in to comment.