javafx.scene.control.Alert.setHeaderText()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中javafx.scene.control.Alert.setHeaderText()方法的一些代码示例,展示了Alert.setHeaderText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alert.setHeaderText()方法的具体详情如下:
包路径:javafx.scene.control.Alert
类名称:Alert
方法名:setHeaderText

Alert.setHeaderText介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void start(Stage primaryStage) {        
  Alert alert = new Alert(AlertType.CONFIRMATION);
  alert.setTitle("Confirmation Dialog");
  alert.setHeaderText("This is a Custom Confirmation Dialog");
  alert.setContentText("We override the style classes of the dialog");
  ...
}

代码示例来源:origin: stackoverflow.com

import javafx.scene.control.Alert
import javafx.scene.control.Alert.AlertType;
import javafx.application.Platform;

public class ClassNameHere
{

  public static void infoBox(String infoMessage, String titleBar)
  {
    /* By specifying a null headerMessage String, we cause the dialog to
      not have a header */
    infoBox(infoMessage, titleBar, null);
  }

public static void infoBox(String infoMessage, String titleBar, String headerMessage)
  {
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle(titleBar);
    alert.setHeaderText(headerMessage);
    alert.setContentText(infoMessage);
    alert.showAndWait();
  }
}

代码示例来源:origin: pmd/pmd

private void showLicensePopup() {
  Alert licenseAlert = new Alert(AlertType.INFORMATION);
  licenseAlert.setWidth(500);
  licenseAlert.setHeaderText("License");
  ScrollPane scroll = new ScrollPane();
  try {
    scroll.setContent(new TextArea(IOUtils.toString(getClass().getResourceAsStream("LICENSE"),
        StandardCharsets.UTF_8)));
  } catch (IOException e) {
    e.printStackTrace();
  }
  licenseAlert.getDialogPane().setContent(scroll);
  licenseAlert.showAndWait();
}

代码示例来源:origin: speedment/speedment

@Override
public Optional<ButtonType> showWarning(String title, String message) {
  final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
  final Scene scene = alert.getDialogPane().getScene();
  BrandUtil.applyBrand(injector, stage, scene);
  alert.setTitle("Confirmation");
  alert.setHeaderText(title);
  alert.setContentText(message);
  alert.setGraphic(FontAwesome.EXCLAMATION_TRIANGLE.view());
  return alert.showAndWait();
}

代码示例来源:origin: speedment/speedment

alert.setHeaderText(title);
alert.setContentText(message);
alert.setGraphic(FontAwesome.EXCLAMATION_TRIANGLE.view());

代码示例来源:origin: stackoverflow.com

public boolean showConfirmDialog(String title, String header, String content, AlertType alertType) {
  final Alert alert = new Alert(alertType);
  alert.setTitle(title);
  alert.setHeaderText(header);
  alert.setContentText(content);

  alert.getButtonTypes().clear();
  alert.getButtonTypes().addAll(ButtonType.YES, ButtonType.NO);

  //Deactivate Defaultbehavior for yes-Button:
  Button yesButton = (Button) alert.getDialogPane().lookupButton( ButtonType.YES );
  yesButton.setDefaultButton( false );

  //Activate Defaultbehavior for no-Button:
  Button noButton = (Button) alert.getDialogPane().lookupButton( ButtonType.NO );
  noButton.setDefaultButton( true );

  final Optional<ButtonType> result = alert.showAndWait();
  return result.get() == ButtonType.YES;
}

代码示例来源:origin: stackoverflow.com

Exception e = new Exception("An exception!!!!!!!!!!!!!!!!!");
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));

Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText("An exception occurred!");
alert.getDialogPane().setExpandableContent(new ScrollPane(new TextArea(sw.toString())));
alert.showAndWait();

代码示例来源:origin: stackoverflow.com

Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Message Here...");
alert.setHeaderText("Look, an Information Dialog");
alert.setContentText("I have a great message for you!");
alert.showAndWait().ifPresent(rs -> {
  if (rs == ButtonType.OK) {
    System.out.println("Pressed OK.");
  }
});

代码示例来源:origin: it.unibo.alchemist/alchemist-projectview

private void setAlert(final String title, final String header, final String content) {
  final Alert alert = new Alert(AlertType.WARNING);
  alert.setTitle(RESOURCES.getString(title));
  alert.setHeaderText(RESOURCES.getString(header));
  alert.setContentText(RESOURCES.getString(content));
  alert.showAndWait();
}

代码示例来源:origin: stackoverflow.com

Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
 alert.setTitle("Confirmation Dialog");
 alert.setHeaderText("Warning !");
 alert.setContentText("Are you sure you want to perform this action ?");
 Optional<ButtonType> result = alert.showAndWait();
 if (result.get() == ButtonType.OK) {
  // delete user
}

代码示例来源:origin: stackoverflow.com

Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Information Dialog");
alert.setHeaderText(null);
alert.setContentText("I have a great message for you!");
alert.showAndWait();

代码示例来源:origin: stackoverflow.com

ButtonType okBtn; //make sure this is of type ButtonBar.ButtonData.OK_DONE
ButtonType cancelBtn; //make sure this is of type ButtonBar.ButtonData.CANCEL_CLOSE
Alert alert = new Alert(AlertType.CONFIRMATION,"",okBtn,cancelBtn);
alert.getDialogPane().setContent(textFlow);

alert.setTitle("Some title");
alert.setHeaderText(null);
Optional<ButtonType> result = alert.showAndWait();

代码示例来源:origin: com.powsybl/powsybl-gse-util

public static Optional<ButtonType> showSaveAndQuitDialog(String documentName) {
  Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
  alert.setHeaderText(MessageFormat.format(RESOURCE_BUNDLE.getString("SaveBeforeClosing"), documentName));
  alert.setContentText(RESOURCE_BUNDLE.getString("WarnSaveBeforeClosing"));
  ButtonType save = new ButtonType(RESOURCE_BUNDLE.getString("Save"), ButtonBar.ButtonData.YES);
  ButtonType dontSave = new ButtonType(RESOURCE_BUNDLE.getString("DontSave"), ButtonBar.ButtonData.NO);
  alert.getButtonTypes().setAll(save, dontSave, ButtonType.CANCEL);
  return alert.showAndWait();
}

代码示例来源:origin: us.ihmc/robot-environment-awareness

private void createWarning()
  {
   Alert connectionLostAlert = new Alert(AlertType.WARNING);
   connectionLostAlert.setHeaderText("Lost connection");
   connectionLostAlert.initOwner(mainWindow);
   connectionLostAlert.showAndWait();
  }
}

代码示例来源:origin: stackoverflow.com

Alert dialog = new Alert(Alert.AlertType.ERROR);
dialog.setHeaderText("Connection Failed");
dialog.setContentText(this.getException().getMessage());

//FIXME: Remove after release 8u40
dialog.setResizable(true);
dialog.getDialogPane().setPrefSize(480, 320);

dialog.showAndWait();

代码示例来源:origin: stackoverflow.com

public void showAlert() {
  Platform.runLater(new Runnable() {
   public void run() {
     Alert alert = new Alert(Alert.AlertType.INFORMATION);
     alert.setTitle("Message Here...");
     alert.setHeaderText("Look, an Information Dialog");
     alert.setContentText("I have a great message for you!");
     alert.showAndWait();
   }
  });
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

public static void showWarning(String title, String message) {
 final Alert alert = new Alert(Alert.AlertType.WARNING);
 alert.initStyle(StageStyle.UTILITY);
 alert.setTitle("Warning");
 alert.setHeaderText(title);
 alert.setContentText(message);
 alert.showAndWait();
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

public static void showInformation(String title, String message) {
 final Alert alert = new Alert(Alert.AlertType.INFORMATION);
 alert.initStyle(StageStyle.UNDECORATED);
 alert.setTitle("Information");
 alert.setHeaderText(title);
 alert.setContentText(message);
 alert.showAndWait();
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

public static void showError(String title, String message) {
 final Alert alert = new Alert(Alert.AlertType.ERROR);
 alert.initStyle(StageStyle.UTILITY);
 alert.setTitle("Error");
 alert.setHeaderText(title);
 alert.setContentText(message);
 alert.showAndWait();
}

代码示例来源:origin: ssaring/sportstracker

@Override
public void showMessageDialog(final Window parent, final Alert.AlertType alertType, final String titleKey,
    final String messageKey, final Object... arguments) {
  final String message = fxResources.getString(messageKey, arguments);
  final Alert alert = new Alert(alertType, message);
  alert.initOwner(parent);
  alert.setTitle(fxResources.getString(titleKey));
  alert.setHeaderText(null);
  alert.showAndWait();
}

相关文章