JavaFX Alert会截断邮件吗? [英] JavaFX Alert truncates the message?
本文介绍了JavaFX Alert会截断邮件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到如果我尝试用长消息显示 Alert
,它往往会被截断(在单词边界处)。
I noticed that if I try to show an Alert
with a long message, it tends to get truncated (at a word boundary).
示例:
import javafx.application.Application;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;
public class AlertTest extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
new Alert(AlertType.INFORMATION, "this is a pretty long message that "
+ "should not be truncated in this alert window, no matter "
+ "how long it is").showAndWait();
}
public static void main(final String... args) {
launch(args);
}
}
这只显示这是一条很长的消息,不应该被截断这里。
截断的原因是什么,我该如何避免?
This only displays "this is a pretty long message that should not be truncated" here.
What is the reason for the truncation, and how can I avoid it?
我正在使用Oracle JDK Linux中的1.8.0_60。
I'm using Oracle JDK 1.8.0_60 in Linux.
推荐答案
我认为这只是Windows和Linux的问题。它不会发生在MacOS上。但是我认为这将在所有平台上为您解决。
I think it's only a Windows and Linux issue. It doesn't happen on MacOS. However I think this will fix it for you on all platforms.
Alert alert = new Alert(AlertType.INFORMATION);
alert.setContentText("this is a pretty long message that "
+ "should not be truncated in this alert window, no matter "
+ "how long it is");
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.showAndWait();
这篇关于JavaFX Alert会截断邮件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文