了JavaFx对话框除去底部空间
问题描述:
考虑下面的代码:了JavaFx对话框除去底部空间
public class Main extends Application {
public static void main(String[] args) throws Exception {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
final BorderPane p = new BorderPane();
final Dialog dialog = new Dialog() { {
getDialogPane().setContent(new Button("TEXT"));
} };
final Button bt = new Button("LAUNCH");
bt.setOnAction(e -> dialog.show());
p.setCenter(bt);
stage.setScene(new Scene(p));
stage.show();
}
}
结果是:
代码被简化例子。
问题在于底部有额外的空间。有什么办法可以删除它吗?谢谢。
答
你可以这样做:
@Override
public void start(Stage stage)
{
final BorderPane p = new BorderPane();
Stage dialog = new Stage();
dialog.initModality(Modality.APPLICATION_MODAL);
dialog.setScene(new Scene(new Button("TEXT")));
final Button bt = new Button("LAUNCH");
bt.setOnAction(e -> dialog.show());
p.setCenter(bt);
stage.setScene(new Scene(p));
stage.show();
}
这将显示在任务栏另一个图标。舞台!=对话 – Mordechai
是的,工作!谢谢! 我在回答之前试图找到这种行为的原因,但没有成功。如果我们使用initStyle(StageStyle.UNDECORATED),底部空间消失,但我们也松动框架! – Dmitry