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

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

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

Alert.initOwner介绍

暂无

代码示例

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

public class Main extends Application {

  @Override
  public void start(final Stage primaryStage) throws Exception {
    final Alert alert = new Alert(Alert.AlertType.INFORMATION);

    primaryStage.setScene(new Scene(new Group(), 300, 300, Color.BLACK));

    alert.initOwner(primaryStage);

    alert.showAndWait();
  }

  public static void main(final String... args) {
    launch(args);
  }

}

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

primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
  @Override
  public void handle(WindowEvent event) {

    // consume event
    event.consume();

    // show close dialog
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Close Confirmation");
    alert.setHeaderText("Do you really want to quit?");
    alert.initOwner( primaryStage);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == ButtonType.OK){
      Platform.exit();
    }
  }
});

代码示例来源: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

JColorChooser colorChooser = new JColorChooser(java.awt.Color.CYAN);

SwingNode colorChooserNode = new SwingNode();
colorChooserNode.setContent(colorChooser);

Alert dialog = new Alert(Alert.AlertType.NONE);
// Guarantees dialog will be above (and will block input to) mainStage.
dialog.initOwner(mainStage);
dialog.setTitle("Select a color");

dialog.getDialogPane().setContent(colorChooserNode);

dialog.getDialogPane().getButtonTypes().setAll(
  ButtonType.OK, ButtonType.CANCEL);

Optional<ButtonType> response = dialog.showAndWait();
if (response.filter(r -> r == ButtonType.OK).isPresent()) {
  int rgb = colorChooser.getColor().getRGB();
  String hex = String.format("#%06x", rgb & 0xffffff);

  Text.setText(hex);
  ShortcutButton.setBackground(new Background(
    new BackgroundFill(Color.valueOf(hex), null, null)));
} else {
  System.out.println("User canceled");
}

代码示例来源:origin: io.github.factoryfx/javafxDataEditing

private void deleteSelected(Window owner) {
  if (uniformDesign.isAskBeforeDelete()){
    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.initOwner(owner);
    alert.setTitle(uniformDesign.getText(deleteConfirmationTitle));
    alert.setHeaderText(uniformDesign.getText(deleteConfirmationHeader));
    alert.setContentText(uniformDesign.getText(deleteConfirmationContent));
    Optional<ButtonType> result = alert.showAndWait();
    if (result.isPresent()){
      if (result.get() != ButtonType.OK){
        return;
      }
    }
  }
  final List<T> selectedItems = new ArrayList<>(tableView.getSelectionModel().getSelectedItems());
  selectedItems.forEach(t -> deleter.accept(t,referenceListAttribute));
}

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

if (textField.getText().trim().isEmpty()) {
  Alert alert2 = new Alert(AlertType.ERROR, "Please enter a value", ButtonType.OK);
  alert2.initOwner(dialog2.getDialogPane().getScene().getWindow());
  alert2.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();
}

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

/**
 * show the given alert
 * 
 * @param stage
 * @param title
 * @param headerText
 * @param content
 * @param alertType
 */
private static void doshowAlert(Stage stage, String title, String headerText,
  String content, AlertType alertType) {
 Alert alert = new Alert(alertType);
 alert.initOwner(stage);
 alert.setTitle(title);
 alert.setHeaderText(headerText);
 alert.setContentText(content);
 alert.showAndWait();
}

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

@Override
public Optional<ButtonType> showConfirmationDialog(final Window parent, final String titleKey,
    final String messageKey, final ButtonType... buttonTypes) {
  final Alert alert = new Alert(Alert.AlertType.CONFIRMATION, fxResources.getString(messageKey));
  alert.initOwner(parent);
  alert.setTitle(fxResources.getString(titleKey));
  alert.setHeaderText(null);
  // add custom button types if specified
  if (buttonTypes.length > 0) {
    alert.getButtonTypes().setAll(buttonTypes);
  }
  return alert.showAndWait();
}

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

alert.initOwner(stage);
alert.getDialogPane().setContentText("Some text");

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

alert.initOwner(stage);
alert.getDialogPane().setContentText("Some text");

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

+ item.toLowerCase() + "?");
alertBox.initOwner(owner);                         /* *** */
alertBox.showAndWait();
if (alertBox.getResult() == ButtonType.OK) {

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

String headerText, Throwable th, Linker linker) {
Alert alert = new Alert(AlertType.ERROR);
alert.initOwner(stage);
alert.setTitle(title);
alert.setHeaderText(headerText);

相关文章