Java 工具提示不换行/忽略最大宽度

Java 工具提示不换行/忽略最大宽度,java,width,tooltip,javafx,word-wrap,Java,Width,Tooltip,Javafx,Word Wrap,我正在尝试向我的切换按钮添加工具提示,向用户解释如果他们按下按钮会发生什么。问题是,当我通过TooltipBuilder设置max/pref width时,我的解释太长了,工具提示用“…”(省略号字符串,是吗?)将其截断,如本例所示: this.watched = new ToggleButton("Watched?"); Tooltip tooltip = TooltipBuilder.create().wrapText(true).text( "Rather

我正在尝试向我的
切换按钮添加工具提示,向用户解释如果他们按下按钮会发生什么。问题是,当我通过
TooltipBuilder
设置max/pref width时,我的解释太长了,工具提示用“…”(省略号字符串,是吗?)将其截断,如本例所示:

this.watched = new ToggleButton("Watched?");
Tooltip tooltip = TooltipBuilder.create().wrapText(true).text(
                "Rather than specifying individual images, you can make this source \'watched\',which means that every" + 
                " time this gallery is viewed, all the images in this directory will be listed.").build();
tooltip.prefWidth(50);
watched.setTooltip(tooltip);
我得到这个结果:

我试图通过
maxWidth(double)
maxWidthProperty().set(double)
prefWidth(double)
prefWidthProperty().set(double)
设置宽度的尝试已被忽略


有什么办法克服这个问题吗?

在我的代码中,我在设置宽度之前设置了
wrapText(布尔值)
。JavaFX似乎不太喜欢这个。我把它改成这样:

TooltipBuilder.create().prefWidth(300).wrapText(true).<other properties>.build();
TooltipBuilder.create().prefWidth(300).wrapText(true)…build();
这给了我一个成功的总结


在JavaFX2.2中,使用以下命令:

Tooltip toolTip = TooltipBuilder.create().text(string).prefWidth(500).wrapText(true).build();

请注意,
TooltipBuilder
在JavaV8更新101中被弃用(尽管它仍然有效)。