adi*_*tsu 4 java javafx javafx-8
我注意到,如果我尝试Alert用长消息显示,它往往会被截断(在单词边界).
例:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
这只显示"这是一个不应该被截断的非常长的消息".
截断的原因是什么,我该如何避免呢?
我在Linux中使用Oracle JDK 1.8.0_60.
Dav*_*ave 10
我认为这只是一个Windows和Linux问题.它不会发生在MacOS上.但是我认为这将在所有平台上为您解决.
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();
Run Code Online (Sandbox Code Playgroud)