JavaFX警报按钮栏大小调整
我有一个JavaFX警报对话框,其中有几个我添加的JavaFX警报按钮栏大小调整,java,javafx,javafx-8,Java,Javafx,Javafx 8,我有一个JavaFX警报对话框,其中有几个我添加的按钮类型 问题是,当我添加较大的按钮(文本较长)时,其余按钮开始从原始大小伸出 像这样: 应该是这样的: 有没有办法让所有的按钮都使用自己喜欢的尺寸 代码如下: ButtonType saveButtonType = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE); ButtonType closeButtonType = new ButtonType("Close",
按钮类型
问题是,当我添加较大的按钮(文本较长)时,其余按钮开始从原始大小伸出
像这样:
应该是这样的:
有没有办法让所有的按钮都使用自己喜欢的尺寸
代码如下:
ButtonType saveButtonType = new ButtonType("Save", ButtonBar.ButtonData.OK_DONE);
ButtonType closeButtonType = new ButtonType("Close", ButtonBar.ButtonData.CANCEL_CLOSE);
ButtonType testButtonType = new ButtonType("LONG BUTTON TEXT", ButtonBar.ButtonData.LEFT);
dialog.getDialogPane().getButtonTypes().addAll(saveButtonType, closeButtonType,testButtonType);
我想出来了:
Button testButton = (Button) dialog.getDialogPane().lookupButton(testButtonType);
ButtonBar.setButtonUniformSize(testButton, false);
我想出来了:
Button testButton = (Button) dialog.getDialogPane().lookupButton(testButtonType);
ButtonBar.setButtonUniformSize(testButton, false);