Java Code Examples for javafx.scene.control.Alert#initOwner()
The following examples show how to use
javafx.scene.control.Alert#initOwner() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeadChooseFrame.java From oim-fx with MIT License | 6 votes |
private void initComponent() { this.setTitle("选择头像"); this.setResizable(false); this.setTitlePaneStyle(2); this.setWidth(430); this.setHeight(580); this.setCenter(p); alert = new Alert(AlertType.CONFIRMATION, ""); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(this); alert.getDialogPane().setContentText("确定选择"); alert.getDialogPane().setHeaderText(null); p.setPrefWrapLength(400); }
Example 2
Source File: MainWindow.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 6 votes |
private void helpAbout() { String version = null; Package pkg = this.getClass().getPackage(); if (pkg != null) version = pkg.getImplementationVersion(); if (version == null) version = "(dev)"; Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle(Messages.get("MainWindow.about.title")); alert.setHeaderText(Messages.get("MainWindow.about.headerText")); alert.setContentText(Messages.get("MainWindow.about.contentText", version)); alert.setGraphic(new ImageView(new Image("org/markdownwriterfx/markdownwriterfx32.png"))); alert.initOwner(getScene().getWindow()); alert.getDialogPane().setPrefWidth(420); alert.showAndWait(); }
Example 3
Source File: ScreensSwitcher.java From mars-sim with GNU General Public License v3.0 | 6 votes |
public boolean exitDialog(Stage stage) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.setTitle("Confirmation for Exit");//("Confirmation Dialog"); alert.setHeaderText("Leaving mars-sim ?"); //alert.initModality(Modality.APPLICATION_MODAL); alert.setContentText("Note: Yes to exit mars-sim"); ButtonType buttonTypeYes = new ButtonType("Yes"); ButtonType buttonTypeNo = new ButtonType("No"); alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonTypeYes){ if (mainMenu.getMultiplayerMode() != null) if (mainMenu.getMultiplayerMode().getChoiceDialog() != null) mainMenu.getMultiplayerMode().getChoiceDialog().close(); alert.close(); Platform.exit(); System.exit(0); return true; } else { alert.close(); return false; } }
Example 4
Source File: NewPurchaseMethodDialogController.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@FXML private void onOk(final ActionEvent actionEvent) { // possibly replace with ControlsFX validation framework if (getEnteredName().isEmpty()) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle(Constants.APPLICATION_NAME); // todo: i18n alert.setContentText("Please enter a name for this method."); alert.initOwner(newPurchaseDialog.getWindow()); alert.showAndWait(); return; } model.setCancelled(false); Platform.runLater(() -> { Window window = newPurchaseDialog.getWindow(); window.hide(); }); }
Example 5
Source File: EditorFrame.java From JetUML with GNU General Public License v3.0 | 6 votes |
/** * If a user confirms that they want to close their modified graph, this method * will remove it from the current list of tabs. * * @param pDiagramTab The current Tab that one wishes to close. */ public void close(DiagramTab pDiagramTab) { if(pDiagramTab.hasUnsavedChanges()) { Alert alert = new Alert(AlertType.CONFIRMATION, RESOURCES.getString("dialog.close.ok"), ButtonType.YES, ButtonType.NO); alert.initOwner(aMainStage); alert.setTitle(RESOURCES.getString("dialog.close.title")); alert.setHeaderText(RESOURCES.getString("dialog.close.title")); alert.showAndWait(); if (alert.getResult() == ButtonType.YES) { removeGraphFrameFromTabbedPane(pDiagramTab); } } else { removeGraphFrameFromTabbedPane(pDiagramTab); } }
Example 6
Source File: BattleLogController.java From logbook-kai with MIT License | 6 votes |
/** * 集計の追加 */ @FXML void addUnitAction(ActionEvent event) { UnitDialog dialog = new UnitDialog(); Alert alert = new Alert(Alert.AlertType.NONE); alert.getDialogPane().getStylesheets().add("logbook/gui/application.css"); InternalFXMLLoader.setGlobal(alert.getDialogPane()); alert.initOwner(this.getWindow()); alert.setTitle("集計の追加"); alert.setDialogPane(dialog); alert.showAndWait().filter(ButtonType.APPLY::equals).ifPresent(b -> { IUnit unit = dialog.getUnit(); if (unit != null) { this.logMap.put(unit, BattleLogs.readSimpleLog(unit)); this.addTree(unit); this.userUnit.add(unit); } }); }
Example 7
Source File: DialogUtils.java From qiniu with MIT License | 5 votes |
public static Alert getAlert(String header, String content, AlertType alertType, Modality modality, Window window , StageStyle style) { Alert alert = new Alert(alertType); alert.setTitle(QiniuValueConsts.MAIN_TITLE); alert.setHeaderText(header); alert.setContentText(content); alert.initModality(modality); alert.initOwner(window); alert.initStyle(style); return alert; }
Example 8
Source File: AlertHelper.java From javase with MIT License | 5 votes |
public static void showAlert(Alert.AlertType alertType, Window owner, String title, String message) { Alert alert = new Alert(alertType); alert.setTitle(title); alert.setHeaderText(null); alert.setContentText(message); alert.initOwner(owner); alert.show(); }
Example 9
Source File: FXUIUtils.java From marathonv5 with Apache License 2.0 | 5 votes |
public static Optional<ButtonType> _showConfirmDialog(Window parent, String message, String title, AlertType type, ButtonType... buttonTypes) { Alert alert = new Alert(type, message, buttonTypes); alert.initOwner(parent); alert.setTitle(title); alert.initModality(Modality.APPLICATION_MODAL); return alert.showAndWait(); }
Example 10
Source File: ApplicationController.java From TerasologyLauncher with Apache License 2.0 | 5 votes |
@FXML protected void deleteAction() { final Path gameDir = packageManager.resolveInstallDir(selectedPackage); final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setContentText(BundleUtils.getMessage("confirmDeleteGame_withoutData", gameDir)); alert.setTitle(BundleUtils.getLabel("message_deleteGame_title")); alert.initOwner(stage); alert.showAndWait() .filter(response -> response == ButtonType.OK) .ifPresent(response -> { logger.info("Removing game: {}-{}", selectedPackage.getId(), selectedPackage.getVersion()); // triggering a game deletion implies the player doesn't want to play this game anymore // hence, we unset `lastPlayedGameJob` and `lastPlayedGameVersion` settings independent of deletion success launcherSettings.setLastPlayedGameJob(""); launcherSettings.setLastPlayedGameVersion(""); deleteButton.setDisable(true); final DeleteTask deleteTask = new DeleteTask(packageManager, selectedVersion); deleteTask.onDone(() -> { packageManager.syncDatabase(); if (!selectedPackage.isInstalled()) { startAndDownloadButton.setGraphic(downloadImage); } else { deleteButton.setDisable(false); } }); executor.submit(deleteTask); }); }
Example 11
Source File: EditorFrame.java From JetUML with GNU General Public License v3.0 | 5 votes |
/** * Exits the program if no graphs have been modified or if the user agrees to * abandon modified graphs. */ public void exit() { final int modcount = getNumberOfUsavedDiagrams(); if (modcount > 0) { Alert alert = new Alert(AlertType.CONFIRMATION, MessageFormat.format(RESOURCES.getString("dialog.exit.ok"), new Object[] { Integer.valueOf(modcount) }), ButtonType.YES, ButtonType.NO); alert.initOwner(aMainStage); alert.setTitle(RESOURCES.getString("dialog.exit.title")); alert.setHeaderText(RESOURCES.getString("dialog.exit.title")); alert.showAndWait(); if (alert.getResult() == ButtonType.YES) { Preferences.userNodeForPackage(UMLEditor.class).put("recent", aRecentFiles.serialize()); System.exit(0); } } else { Preferences.userNodeForPackage(UMLEditor.class).put("recent", aRecentFiles.serialize()); System.exit(0); } }
Example 12
Source File: MainAction.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
public void deleteRedisKeyAction() { ObservableList list = mc.redisValueTable.getSelectionModel().getSelectedItems(); if (list.isEmpty()) { Toast.makeText("请选择要删除的记录").show(mc.pane.getScene().getWindow()); return; } StringBuilder key = new StringBuilder(); int i = 0; for (Object object : list) { Map mp = (Map) object; key.append(mp.get("key")); if (i != list.size() - 1) { key.append(","); } i++; } Alert a = new Alert(Alert.AlertType.CONFIRMATION); a.setTitle("确认删除"); a.setContentText("确认要删除[" + key + "]这些键值吗?"); a.initOwner(mc.pane.getScene().getWindow()); Optional<ButtonType> o = a.showAndWait(); if (o.get().getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) { String[] keys = key.toString().split(","); String name = (String) mc.redisDatabaseList.getSelectionModel().getSelectedItem(); RedisUtil.deleteKeys(name, keys); Toast.makeText("删除成功", Duration.seconds(1)).show(mc.pane.getScene().getWindow()); mc.paginationForValue.getPageFactory().call(0); } }
Example 13
Source File: ErrorPopupView.java From standalone-app with Apache License 2.0 | 5 votes |
private Alert get() { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("An error has occurred!"); alert.setHeaderText(headerText); alert.setContentText(message); alert.initOwner(mainStage); return alert; }
Example 14
Source File: WarningPopupView.java From standalone-app with Apache License 2.0 | 5 votes |
private Alert get() { Alert alert = new Alert(Alert.AlertType.WARNING); alert.setTitle("Warning!"); alert.setHeaderText(headerText); alert.setContentText(message); alert.initOwner(mainStage); return alert; }
Example 15
Source File: InfoPopupView.java From standalone-app with Apache License 2.0 | 5 votes |
private Alert get() { Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.setTitle("Info!"); alert.setHeaderText(headerText); alert.setContentText(message); alert.initOwner(mainStage); return alert; }
Example 16
Source File: PinPeer.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void mousePressed(CircuitManager manager, CircuitState state, double x, double y) { if(!isInput()) { return; } if(state != manager.getCircuit().getTopLevelState()) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(manager.getSimulatorWindow().getStage()); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Switch to top-level state?"); alert.setHeaderText("Switch to top-level state?"); alert.setContentText("Cannot modify state of a subcircuit. Switch to top-level state?"); Optional<ButtonType> buttonType = alert.showAndWait(); if(buttonType.isPresent() && buttonType.get() == ButtonType.OK) { state = manager.getCircuit().getTopLevelState(); manager.getCircuitBoard().setCurrentState(state); } else { return; } } Pin pin = getComponent(); WireValue value = state.getLastPushed(pin.getPort(Pin.PORT)); if(pin.getBitSize() == 1) { pin.setValue(state, new WireValue(1, value.getBit(0) == State.ONE ? State.ZERO : State.ONE)); } else { double bitWidth = getScreenWidth() / Math.min(8.0, pin.getBitSize()); double bitHeight = getScreenHeight() / ((pin.getBitSize() - 1) / 8 + 1.0); int bitCol = (int)(x / bitWidth); int bitRow = (int)(y / bitHeight); int bit = pin.getBitSize() - 1 - (bitCol + bitRow * 8); if(bit >= 0 && bit < pin.getBitSize()) { WireValue newValue = new WireValue(value); newValue.setBit(bit, value.getBit(bit) == State.ONE ? State.ZERO : State.ONE); pin.setValue(state, newValue); } } }
Example 17
Source File: EditorFrame.java From JetUML with GNU General Public License v3.0 | 4 votes |
private void saveAs() { DiagramTab diagramTab = getSelectedDiagramTab(); Diagram diagram = diagramTab.getDiagram(); FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll(FileExtensions.all()); fileChooser.setSelectedExtensionFilter(FileExtensions.forDiagramType(diagram.getType())); if(diagramTab.getFile().isPresent()) { fileChooser.setInitialDirectory(diagramTab.getFile().get().getParentFile()); fileChooser.setInitialFileName(diagramTab.getFile().get().getName()); } else { fileChooser.setInitialDirectory(getLastDir(KEY_LAST_SAVEAS_DIR)); fileChooser.setInitialFileName(""); } try { File result = fileChooser.showSaveDialog(aMainStage); if( result != null ) { PersistenceService.save(diagram, result); addRecentFile(result.getAbsolutePath()); diagramTab.setFile(result); diagramTab.setText(diagramTab.getFile().get().getName()); diagramTab.diagramSaved(); File dir = result.getParentFile(); if( dir != null ) { setLastDir(KEY_LAST_SAVEAS_DIR, dir); } } } catch (IOException exception) { Alert alert = new Alert(AlertType.ERROR, RESOURCES.getString("error.save_file"), ButtonType.OK); alert.initOwner(aMainStage); alert.showAndWait(); } }
Example 18
Source File: DisplayEditorApplication.java From phoebus with Eclipse Public License 1.0 | 4 votes |
private URI getFileResource(final URI original_resource) { try { // Strip query from resource, because macros etc. // are only relevant to runtime, not to editor final URI resource = new URI(original_resource.getScheme(), original_resource.getUserInfo(), original_resource.getHost(), original_resource.getPort(), original_resource.getPath(), null, null); // Does the resource already point to a local file? File file = ModelResourceUtil.getFile(resource); if (file != null) { last_local_file = file; return file.toURI(); } // Does user want to download into local file? final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100); alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow()); alert.setResizable(true); alert.setTitle(Messages.DownloadTitle); alert.setHeaderText(MessageFormat.format(Messages.DownloadPromptFMT, resource.toString())); // Setting "Yes", "No" buttons alert.getButtonTypes().clear(); alert.getButtonTypes().add(ButtonType.YES); alert.getButtonTypes().add(ButtonType.NO); if (alert.showAndWait().orElse(ButtonType.NO) == ButtonType.NO) return null; // Prompt for local file final File local_file = promptForFilename(Messages.DownloadTitle); if (local_file == null) return null; // In background thread, .. JobManager.schedule(Messages.DownloadTitle, monitor -> { monitor.beginTask("Download " + resource); // .. download resource into local file .. try ( final InputStream read = ModelResourceUtil.openResourceStream(resource.toString()); ) { Files.copy(read, local_file.toPath(), StandardCopyOption.REPLACE_EXISTING); } // .. and then, back on UI thread, open editor for the local file Platform.runLater(() -> create(ResourceParser.getURI(local_file))); }); // For now, return null, no editor is opened right away. } catch (Exception ex) { ExceptionDetailsErrorDialog.openError("Error", "Cannot load " + original_resource, ex); } return null; }
Example 19
Source File: MainAction.java From DevToolBox with GNU Lesser General Public License v2.1 | 4 votes |
public void checkUpdateAction() { try { HttpRequestData.Request req = new HttpRequestData.Request(); req.setUrl(updateURL); req.setMethod(RequestMethod.GET.toString()); req.setTimeout("10000"); req.setCharset(Charset.UTF8.getCode()); HttpResponse resp = HttpClientUtil.sendRequest(req); String respBody = EntityUtils.toString(resp.getEntity(), req.getCharset()); JsonObject json = gson.fromJson(respBody, JsonObject.class); String cur = Undecorator.LOC.getString("VersionCode"); if (Integer.parseInt(cur) < json.get("version").getAsInt()) { Alert a = new Alert(Alert.AlertType.CONFIRMATION); a.setTitle("版本更新"); a.setContentText("当前版本:" + cur + "\n最新版本:" + json.get("version") + "\n更新内容:\n" + json.get("message").getAsString()); a.initOwner(mc.pane.getScene().getWindow()); Optional<ButtonType> o = a.showAndWait(); if (o.get().getButtonData().equals(ButtonBar.ButtonData.OK_DONE)) { String dir = System.getProperty("user.dir"); HttpClientUtil.downloadFile(json.get("url").getAsString(), dir + "/开发辅助.jar.update"); a.setContentText("下载完成,请重启程序。"); a.setAlertType(Alert.AlertType.INFORMATION); a.showAndWait(); File f = new File(dir + "/update.jar"); StringBuilder sb = new StringBuilder(); System.getenv().entrySet().forEach((entry) -> { String key = entry.getKey(); String value = entry.getValue(); sb.append(key).append("=").append(value).append("#"); }); Runtime.getRuntime().exec("java -jar update.jar", sb.toString().split("#"), f.getParentFile()); System.exit(0); } } else { Toast.makeText("当前已是最新版本", Duration.seconds(1)).show(mc.pane.getScene().getWindow()); } } catch (Exception ex) { Toast.makeText("检查更新异常:" + ex.getLocalizedMessage()).show(mc.pane.getScene().getWindow()); LOGGER.error(ex.getLocalizedMessage(), ex); } }
Example 20
Source File: UserHeadUploadFrame.java From oim-fx with MIT License | 4 votes |
private void initComponent() { this.setWidth(390); this.setHeight(518); this.setResizable(false); this.setTitlePaneStyle(2); this.setRadius(5); this.setCenter(rootPane); this.setTitle("更换头像"); imageFileChooser = new FileChooser(); imageFileChooser.getExtensionFilters().add(new ExtensionFilter("图片文件", "*.png", "*.jpg", "*.bmp", "*.gif")); imagePane.setCoverSize(350, 350); openButton.setText("上传头像"); selectButton.setText("选择系统头像"); openButton.setPrefSize(130, 30); selectButton.setPrefSize(130, 30); buttonBox.setPadding(new Insets(12, 10, 12, 14)); buttonBox.setSpacing(10); buttonBox.getChildren().add(openButton); buttonBox.getChildren().add(selectButton); pane.setTop(buttonBox); pane.setCenter(imagePane); titleLabel.setText("更换头像"); titleLabel.setFont(Font.font("微软雅黑", 14)); titleLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1)"); topBox.setStyle("-fx-background-color:#2cb1e0"); topBox.setPrefHeight(30); topBox.setPadding(new Insets(5, 10, 5, 10)); topBox.setSpacing(10); topBox.getChildren().add(titleLabel); alert = new Alert(AlertType.CONFIRMATION, ""); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(this); alert.getDialogPane().setContentText("确定选择"); alert.getDialogPane().setHeaderText(null); cancelButton.setText("取消"); cancelButton.setPrefWidth(80); doneButton.setText("确定"); doneButton.setPrefWidth(80); bottomBox.setStyle("-fx-background-color:#c9e1e9"); bottomBox.setAlignment(Pos.BASELINE_RIGHT); bottomBox.setPadding(new Insets(5, 10, 5, 10)); bottomBox.setSpacing(10); bottomBox.getChildren().add(doneButton); bottomBox.getChildren().add(cancelButton); rootPane.setTop(topBox); rootPane.setCenter(pane); rootPane.setBottom(bottomBox); Image coverImage = ImageBox.getImageClassPath("/classics/images/cropper/CircleMask.png"); imagePane.setCoverImage(coverImage); }