Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label text position

I have a Label with an image and text

final Label label = new Label(labelText);
label.setTextAlignment(TextAlignment.CENTER);

ImageView livePerformIcon = new ImageView(MainApp.class.getResource("/images/Folder-icon.png").toExternalForm());
label.setGraphic(livePerformIcon);

I get this as a visual result:

enter image description here

How I can change the text position? I want to set the text below the Image?

like image 702
Peter Penzov Avatar asked Mar 24 '14 12:03

Peter Penzov


People also ask

How do I align text in labels?

We specify the margin-bottom of our <div> element. Then, we set the display of the <label> element to "inline-block" and give a fixed width. After that, set the text-align property to "right", and the labels will be aligned with the inputs on the right side.

How do I move the position of a label in HTML?

Change element label position for all elementsClick on the Settings icon on the right side of your map. Click MORE OPTIONS, and select Customize defaults. Look for "Default label position" under "Element defaults". You can change the position of the labels to "bottom" or "center."

Should labels be on the left or right?

Designers should avoid left aligning labels to fields and right align them instead. This brings the label closer to the field to make scanning the form faster and easier. Labels left aligned to fields often create large white space between the label and field.


1 Answers

I had to center the text of a label which acted like a title. The following code snippet did the trick.

        final Label title = new Label("Some text");
        title.setMaxWidth(Double.MAX_VALUE);
        title.setAlignment(Pos.CENTER);

Good programming :-)

like image 50
Alessandro Giusa Avatar answered Sep 23 '22 14:09

Alessandro Giusa