【问题标题】:Change size of Alert Dialog buttons更改警报对话框按钮的大小
【发布时间】:2015-08-10 15:38:03
【问题描述】:

我在更改警报按钮的大小时遇到​​问题。

  Alert alert = new Alert(alertType);
  alert.setTitle(titulo);
  alert.setHeaderText(encabezado);
  alert.setContentText(mensaje);

  ButtonType button1 = new ButtonType(mensajeBoton1);
  ButtonType button2 = new ButtonType(mensajeBoton2);

  alert.getButtonTypes().setAll(button1, button2);

  Optional<ButtonType> result = alert.showAndWait();

  if (result.get() == button1) {
      return Dialog.Actions.OK;
  }

问题是因为buttonType很小,而且是在触摸屏上使用的。

【问题讨论】:

    标签: css javafx javafx-8


    【解决方案1】:

    您可以通过dialogPane.lookupButton() 访问它们并对其应用自定义样式:

    for ( ButtonType bt : alert.getDialogPane().getButtonTypes() )
    {
        Button button = ( Button ) alert.getDialogPane().lookupButton( bt );
        button.setPadding( new Insets( 20 ) );
    
        // or define css style and apply it
        button.getStyleClass().add( "big-button" );
    }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-21
    • 1970-01-01
    • 2012-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-03
    相关资源
    最近更新 更多