Answer the question
In order to leave comments, you need to log in
How to find out if there is an ellipsis in the text of the label?
Application in JavaFX, I have a label. It will contain different text. When the text becomes larger than the size of the label, it is cut off and 3 dots (ellipsis) appear in place of the last characters.
I need that when the text goes beyond the label and elipsis appears, the font size of the text decreases, for example by 30%, so that the text fits completely into the label.
How do I know if the label has ellipsis?
How can you get ellipsis?
I tried instead of 3 dots ellipsis to replace with other characters, and then use the method contains()
to check if these characters are in the text of the label, but Java does not find these characters, it seems that the ellipsis characters are not available to the method. contains()
Perhaps because Java does not replace the truncated text with ellipsis , and imposes on top of it
@FXML private Label label;
if(label.contains("...") {
label.setFont(Font.font("Serif", 55));
}
Answer the question
In order to leave comments, you need to log in
try
label.setOnMouseEntered(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
System.err.println(String.format("The label.bounds: %.2f %.2f,
Math.floor(label.getBoundsInLocal().getWidth()),
Math.floor(label.getBoundsInLocal().getHeight())));
label.setScaleX(0.82);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question