My question is that can I catch the event of display "..." ?
※ I mean does javaFX have a API to judge if the end of the content is replaced with "..."?
In fact, the reason for my question is that now our testers want us to set a TIP on one controller(like Label) if it is only not enough to display. If the content is enough to display in the controller, we don't need to add a TIP then.
There's no easy way of telling if a text has been clipped.
This clipping is done on Labeled objects, and in the implementation of LabeledSkinBase, we can see that all the logic for clipping is delegated to computeClippedText(), which returns a (clipped or not) String:
result = Utils.computeClippedText(font, s, w, truncationStyle, ellipsisString);
[...]
text.setText(result);
This method does not get a reference to the Labeled object and does not fire any events, so the only chance we have of whether computeClippedText() decided to clip is to have a look at the actual Text node (text), which contains the actual text being shown. Since Labeled doesn't expose this node, we have to resort to doing a lookup:
String originalString = myLabeled.getText();
Text textNode = (Text) myLabeled.lookup(".text"); // "text" is the style class of Text
String actualString = textNode.getText();
contentHasBeenClipped = originalString.notEquals(actualString);
And there we have it!
There is an API for specifying the style of the overrun text:
http://docs.oracle.com/javafx/2/api/javafx/scene/control/Labeled.html#textOverrunProperty
http://docs.oracle.com/javafx/2/api/javafx/scene/control/Labeled.html#ellipsisStringProperty
http://docs.oracle.com/javafx/2/api/javafx/scene/control/Labeled.html#wrapTextProperty
But I'm not aware of any API to detect that an overrun occured. Maybe this would be a good enhancement request? You could file it here:
http://javafx-jira.kenai.com/