简体   繁体   中英

JavaFX: New line spacing between texts in TextFlow

How can I reduce the space between the 2 texts?

I have the following code:

Text t1 = new Text("Header Text");
Text t2 = new Text("\nBody Text");
TextFlow textFlow = new TextFlow(t1,t2);
textFlow.setTextAlignment(TextAlignment.CENTER);
textFlow.setPadding(new Insets(0));

The gap between "Header Text" and "Body Text" is too wide, is there any way i can reduce this space? I'm using JavaFX Text.

You can set line spacing for a TextFlow . The default value is already 0, so you can make them look closer to each other by giving a negative value:

textFlow.setLineSpacing(-2.0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM