Disable spacing between items in TextFlow in JavaFX -
i'm trying make line of text consists of name , string of text. want name hyperlink , rest plain text.
i thought textflow this, problem automatically puts single space between hyperlink , text. if want textflow example
jane's awesome
the textflow make a
jane 's awesome
is there method or css property disable behaviour?
solution
you can remove padding via css style:
.hyperlink { -fx-padding: 0; }
or can in code if wish:
link.setpadding(new insets(0));
background
the default setting can found in modena.css
file in jfxrt.jar
file packaged jre distribution , is:
-fx-padding: 0.166667em 0.25em 0.166667em 0.25em; /* 2 3 2 3 */
sample application
in sample screenshot second hyperlink has focus (hence dashed border).
import javafx.application.application; import javafx.geometry.insets; import javafx.scene.scene; import javafx.scene.control.hyperlink; import javafx.scene.layout.pane; import javafx.scene.text.text; import javafx.scene.text.textflow; import javafx.stage.stage; public class hyperspace extends application { @override public void start(stage stage) { textflow textflow = new textflow( unstyle(new hyperlink("jane")), new text("'s awesome "), unstyle(new hyperlink("links")) ); stage.setscene(new scene(new pane(textflow))); stage.show(); } private hyperlink unstyle(hyperlink link) { link.setpadding(new insets(0)); return link; } public static void main(string[] args) { launch(args); } }
Comments
Post a Comment