Will JavaFX alert truncate messages?

See English answers > JavaFX alerts and their size 4

Example:

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 shows "this is a very long message that should not be truncated." What is the reason for truncation and how can I avoid it?

I use Oracle JDK 1.8 in Linux 0_ sixty

Solution

I think it's just a windows and Linux problem It won't happen on MacOS But I think this will be solved 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();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>