简体   繁体   中英

How can I set JavaFX dialog height?

How can I set JavaFX alert height in which dialog's contentText is null ? I made an alert and set contentText as null, but dialog's contentText field's height does not became smaller. How can I make contentText field's height as minimum?

Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("title");
alert.setHeaderText("I want to make dialog without contenttext");
alert.setContentText(null);    //this is null but this field is still remain

I just tried like this.

alert.getDialogPane().setMaxHeight(10); //does not work.

Using this method you can customize the size of the alert.

alert.getDialogPane().setMaxSize(2,2);

Default Preview

在此处输入图片说明

Preview after the code

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM