nus-cs2103-AY2425S1 / forum

12 stars 0 forks source link

Font and font size causing ellipses to appear instead. #202

Open daronoh opened 1 week ago

daronoh commented 1 week ago

While playing around with JavaFX, I wanted to change the font and font size of my label in my DialogBox.

<Label fx:id="dialog" text="Label" wrapText="true" minHeight="-Infinity">
            <padding>
                <Insets top="0" right="10" bottom="0" left="10"/>
            </padding>
            <style>
                -fx-font-family: Arial;
                -fx-font-size: 10pt;
            </style>
</Label>

however, when I did this, I noticed that now, whenever I have a label that ends with a new line ("\n"), it turns the last line into an ellipses.

for example, given a response of:

"1.[T][X] read book\n" +
"2.[D][ ] return book (by: June 6th)\n" +
"3.[E][ ] project meeting (from: Aug 6th 2pm to: 4pm)\n" +
"4.[T][X] join sports club\n" +
"5.[T][ ] borrow book\n"

it would show: 1.[T][X] read book 2.[D][ ] return book (by: June 6th) 3.[E][ ] project meeting (from: Aug 6th 2pm to: 4pm) 4.[T][X] join sports club ...

I thought that by having wrapText="true" and minHeight="-Infinity", it would prevent ellipses from happening. Does anyone know why this is happening?

nus-se-bot commented 1 week ago

Tagging a few other students (randomly selected) who have completed related increments, in case they can pitch in: @starchypotatocode @The0nlyJuan @weiliann @dominic2412 @karthickkc @ywllowsensor @harithh07 @vinceg4 @JYL27 @Ansel-Ch @weijianwong @Domokunx @CJianzhi @Teddayz @gnoossk Others are welcome to pitch in too.

Domokunx commented 1 week ago

Maybe the Height of the HBox which contains your Label is preventing the overflow from occurring and results in the ellipsis.

Try messing around with the HBox attributes? I'm new to JavaFx too so it's just a guess.

starchypotatocode commented 1 week ago

I pasted your code inside my .fxml and didn't have the problem you posted, so it's probably not that. Did you copy the code from the tutorial correctly? (Can you show us the full .fxml file?)

harithh07 commented 1 week ago

I played around with SceneBuilder and managed to fix the same problem with my GUI, changing the preferred height of the HBox and Label to use computed size and the HGrow of the Label to "ALWAYS" seemed to fix it for me. I think the max height for both the HBox and Label need to be max value as well.

winstonlimjy commented 1 week ago

Im not sure whats the reason behind it too, in the tutorial, we used the default font and font size i believe. When u play around with different font, it seems to overrun the text into ellipsis.

image --> With default font

image --> same with Arial font, size 13.

woke02 commented 1 week ago

Hi, try setting HGrow of the Label to "ALWAYS", it worked for me

nus-se-bot commented 1 day ago

@daronoh A gentle reminder to close this issue if the problem has been resolved. If not resolved yet, please post a comment explaining which part of the problem/question remains unresolved.