【发布时间】:2015-06-05 16:57:27
【问题描述】:
我有一个动态构建的字符串,它有时太长,但仍需要完全显示给用户。我宁愿让文本滚动而不是为其创建工具提示。
我已经用这个创建了一个标签:
Label text = new Label("hello there i hope this text is long enough to take up space");
TranslateTransition tran = new TranslateTransition(Duration.millis(75000));
tran.setNode(text);
tran.setByX(-400);
tran.setInterpolator(Interpolator.LINEAR);
tran.setCycleCount(Timeline.INDEFINITE);
// add the text
tran.play();
一,当我这样做时,如果文本是 "this is really long" 并且它被缩短为 "this is really..." 那么当标签滚动时,文本仍然是 "this is really..."。另一件事是这会滚动标签,改变元素的 x 位置。有没有办法只改变滚动实例的文本?
另外,有没有办法以编程方式确定给定文本对于指定区域是否会太大?
【问题讨论】:
-
参见 this answer 创建选取框控制器。
标签: css javafx javafx-2 javafx-8 horizontal-scrolling