Remove padding/margin from JavaFX Label

前端 未结 4 1774
长情又很酷
长情又很酷 2020-12-11 03:44

Is there a way to remove the default space (padding/margin) that JavaFX label adds? I want to get rid of the space displayed between the black lines on the image below:

4条回答
  •  离开以前
    2020-12-11 04:23

    One of the more dynamic ways to do this is to use a Text instead of a Label and set the boundsType as VISUAL. This results in a Text without any padding on the any of the sides of the Text, irrespective of the font size.

    Text text = new Text();
    text.setBoundsType(TextBoundsType.VISUAL);
    

提交回复
热议问题