相关疑难解决方法(0)

JavaFX警报及其大小

最近,JavaFX引入了Alerts(Java 8u40).

考虑下面的代码示例.如何显示长度超过几个字的完整消息?我的消息(contentText属性)在最后被删除,...并且警报在我看来没有正确调整其大小.

在我的带有Oracle JDK 8u40的Linux机器上,我只看到了文本This is a long text. Lorem ipsum dolor sit amet,在某些情况下它太短了.

当然,用户可以手动调整警报窗口的大小,并相应地显示文本,但这根本不是用户友好的.

编辑:Windows 7和Linux的屏幕截图(来自Oracle的JDK): Windows警报 Linux警报

import javafx.application.Application;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.stage.Stage;


public class TestAlert extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Alert a = new Alert(AlertType.INFORMATION);
        a.setTitle("My Title");
        a.setHeaderText("My Header Text");
        a.setResizable(true);
        String version = System.getProperty("java.version");
        String content = String.format("Java: %s.\nThis is a long text. Lorem ipsum …
Run Code Online (Sandbox Code Playgroud)

java alert dialog javafx

33
推荐指数
3
解决办法
3万
查看次数

标签 统计

alert ×1

dialog ×1

java ×1

javafx ×1