Java Code Examples for javafx.scene.control.Alert#initModality()
The following examples show how to use
javafx.scene.control.Alert#initModality() .
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: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 7 votes |
boolean confirmAndDeleteCircuit(CircuitManager circuitManager, boolean removeTab) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Delete \"" + circuitManager.getName() + "\"?"); alert.setHeaderText("Delete \"" + circuitManager.getName() + "\"?"); alert.setContentText("Are you sure you want to delete this circuit?"); Optional<ButtonType> result = alert.showAndWait(); if(!result.isPresent() || result.get() != ButtonType.OK) { return false; } else { deleteCircuit(circuitManager, removeTab, true); return true; } }
Example 2
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 3
Source File: FXUIUtils.java From marathonv5 with Apache License 2.0 | 6 votes |
public static void _showMessageDialog(Window parent, String message, String title, AlertType type, boolean monospace) { Alert alert = new Alert(type); alert.initOwner(parent); alert.setTitle(title); alert.setHeaderText(title); alert.setContentText(message); alert.initModality(Modality.APPLICATION_MODAL); alert.setResizable(true); if (monospace) { Text text = new Text(message); alert.getDialogPane().setStyle("-fx-padding: 0 10px 0 10px;"); text.setStyle(" -fx-font-family: monospace;"); alert.getDialogPane().contentProperty().set(text); } alert.showAndWait(); }
Example 4
Source File: LauncherUpdater.java From TerasologyLauncher with Apache License 2.0 | 5 votes |
private FutureTask<Boolean> getUpdateDialog(Stage parentStage, GHRelease release) { final String infoText = " " + BundleUtils.getLabel("message_update_current") + " " + currentVersion.getValue() + " \n" + " " + BundleUtils.getLabel("message_update_latest") + " " + versionOf(release).getValue() + " "; return new FutureTask<>(() -> { Parent root = BundleUtils.getFXMLLoader("update_dialog").load(); ((TextArea) root.lookup("#infoTextArea")).setText(infoText); ((TextArea) root.lookup("#changelogTextArea")).setText(release.getBody()); final Alert alert = new Alert(Alert.AlertType.CONFIRMATION); alert.setTitle(BundleUtils.getLabel("message_update_launcher_title")); alert.setHeaderText(BundleUtils.getLabel("message_update_launcher")); alert.getDialogPane().setContent(root); alert.initOwner(parentStage); alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO); alert.initModality(Modality.APPLICATION_MODAL); alert.setResizable(true); return alert.showAndWait() .filter(response -> response == ButtonType.YES) .isPresent(); }); }
Example 5
Source File: MultiplayerTray.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void createAlert(String text) { //Stage stage = new Stage(); stage.getIcons().add(new Image(this.getClass().getResource("/icons/lander_hab.svg").toString())); String header = null; //String text = null; if (multiplayerClient != null) { header = "Multiplayer Client Connector"; } //System.out.println("confirm dialog pop up."); Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.setTitle("Mars Simulation Project"); alert.setHeaderText(header); alert.setContentText(text); alert.initModality(Modality.APPLICATION_MODAL); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.YES){ notificationTimer.cancel(); Platform.exit(); tray.remove(trayIcon); System.exit(0); } //else { //} }
Example 6
Source File: MultiplayerClient.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void createAlert(String header, String content) { alert = new Alert(AlertType.INFORMATION); alert.initModality(Modality.NONE); alert.setTitle("Mars Simulation Project"); // alert.initOwner(mainMenu.getStage()); alert.setHeaderText("Multiplayer Client"); alert.setContentText(content); // "Connection verified with " + address alert.show(); }
Example 7
Source File: MultiplayerTray.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void createAlert(String text) { //Stage stage = new Stage(); stage.getIcons().add(new Image(this.getClass().getResource("/icons/lander_hab.svg").toString())); String header = null; //String text = null; header = "Multiplayer Host Server"; //System.out.println("confirm dialog pop up."); Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.setTitle("Mars Simulation Project"); alert.setHeaderText(header); alert.setContentText(text); alert.initModality(Modality.APPLICATION_MODAL); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.YES){ if (multiplayerServer != null) { // TODO: fix the loading problem for server mode multiplayerServer.setServerStopped(true); } notificationTimer.cancel(); Platform.exit(); tray.remove(trayIcon); System.exit(0); } //else { //} }
Example 8
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void saveCircuitsInternal() { try { saveCircuits(); } catch(Exception exc) { exc.printStackTrace(); Alert alert = new Alert(AlertType.ERROR); alert.initOwner(stage); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Error"); alert.setHeaderText("Error saving circuit."); alert.setContentText("Error when saving the circuit: " + exc.getMessage()); alert.showAndWait(); } }
Example 9
Source File: CircuitSim.java From CircuitSim with BSD 3-Clause "New" or "Revised" License | 5 votes |
private boolean checkUnsavedChanges() { clearSelection(); if(editHistory.editStackSize() != savedEditStackSize) { Alert alert = new Alert(AlertType.CONFIRMATION); alert.initOwner(stage); alert.initModality(Modality.WINDOW_MODAL); alert.setTitle("Unsaved changes"); alert.setHeaderText("Unsaved changes"); alert.setContentText("There are unsaved changes, do you want to save them?"); ButtonType discard = new ButtonType("Discard", ButtonData.NO); alert.getButtonTypes().add(discard); Optional<ButtonType> result = alert.showAndWait(); if(result.isPresent()) { if(result.get() == ButtonType.OK) { saveCircuitsInternal(); return saveFile == null; } else { return result.get() == ButtonType.CANCEL; } } } return false; }
Example 10
Source File: App.java From DeskChan with GNU Lesser General Public License v3.0 | 5 votes |
static void showThrowable(String sender, String className, String message, List<StackTraceElement> stacktrace) { if (!Main.getProperties().getBoolean("error-alerting", true)) return; Alert alert = new Alert(Alert.AlertType.ERROR); ((Stage) alert.getDialogPane().getScene().getWindow()).getIcons().add(new Image(App.ICON_URL.toString())); alert.setTitle(Main.getString("error")); alert.initModality(Modality.WINDOW_MODAL); alert.setHeaderText(className + " " + Main.getString("caused-by") + " " + sender); alert.setContentText(message); StringBuilder exceptionText = new StringBuilder (); for (Object item : stacktrace) exceptionText.append((item != null ? item.toString() : "null") + "\n"); TextArea textArea = new TextArea(exceptionText.toString()); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); CheckBox checkBox = new CheckBox(Main.getString("enable-error-alert")); checkBox.setSelected(Main.getProperties().getBoolean("error-alerting", true)); checkBox.selectedProperty().addListener((obs, oldValue, newValue) -> { Main.getProperties().put("error-alerting", newValue); }); BorderPane pane = new BorderPane(); pane.setTop(checkBox); pane.setCenter(textArea); alert.getDialogPane().setExpandableContent(pane); alert.show(); }
Example 11
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 12
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 13
Source File: LoadDialog.java From Animu-Downloaderu with MIT License | 5 votes |
public static void showDialog(Window owner, String title, Message message) { alert = new Alert(AlertType.NONE); alert.initOwner(owner); alert.setTitle(title); ObservableMap<String, String> messages = message.getMessages(); StringBuilder msg = new StringBuilder(); messages.forEach((key, value) -> msg.append(String.format("%s\t: %s%n", key, value))); alert.getDialogPane().setMinHeight(messages.size() * 30d); alert.setContentText(msg.toString()); // Run with small delay on each change messages.addListener((Change<? extends String, ? extends String> change) -> Platform.runLater(() -> { StringBuilder msgChange = new StringBuilder(); messages.forEach((key, value) -> msgChange.append(String.format("%s\t: %s%n", key, value))); alert.setContentText(msgChange.toString()); if (messages.values().stream().allMatch(val -> val.startsWith(Message.processed))) { stopDialog(); message.clearMessages(); } })); alert.initModality(Modality.APPLICATION_MODAL); alert.getDialogPane().getStylesheets() .add(LoadDialog.class.getResource("/css/application.css").toExternalForm()); // Calculate the center position of the parent Stage double centerXPosition = owner.getX() + owner.getWidth() / 2d; double centerYPosition = owner.getY() + owner.getHeight() / 2d; alert.setOnShowing(e -> { alert.setX(centerXPosition - alert.getDialogPane().getWidth() / 2d); alert.setY(centerYPosition - alert.getDialogPane().getHeight() / 2d); }); alert.show(); }
Example 14
Source File: PainteraAlerts.java From paintera with GNU General Public License v2.0 | 5 votes |
public static Alert versionDialog() { final TextField versionField = new TextField(Version.VERSION_STRING); versionField.setEditable(false); versionField.setTooltip(new Tooltip(versionField.getText())); final HBox versionBox = new HBox(new Label("Paintera Version"), versionField); HBox.setHgrow(versionField, Priority.ALWAYS); versionBox.setAlignment(Pos.CENTER); final Alert alert = PainteraAlerts.alert(Alert.AlertType.INFORMATION, true); alert.getDialogPane().setContent(versionBox); alert.setHeaderText("Paintera Version"); alert.initModality(Modality.NONE); return alert; }
Example 15
Source File: UserHeadEditViewImpl.java From oim-fx with MIT License | 5 votes |
private void initEvent() { alert = new Alert(AlertType.CONFIRMATION, ""); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(frame); alert.getDialogPane().setContentText("确定选择"); alert.getDialogPane().setHeaderText(null); frame.setWidth(430); frame.setHeight(580); frame.setResizable(false); frame.setTitlePaneStyle(2); frame.setTitle("选择头像"); frame.setCenter(p); frame.show(); p.setPrefWrapLength(400); p.showWaiting(true, WaitingPane.show_waiting); appContext.add(new ExecuteTask() { @Override public void execute() { init(p); } }); }
Example 16
Source File: MainViewImpl.java From oim-fx with MIT License | 5 votes |
protected Alert createAlert() { Alert alert = new Alert(AlertType.INFORMATION, ""); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(mainFrame); alert.getDialogPane().setContentText("你的帐号在其他的地方登录!"); alert.getDialogPane().setHeaderText(null); return alert; }
Example 17
Source File: MainViewImpl.java From oim-fx with MIT License | 5 votes |
protected Alert createAlert() { Alert alert = new Alert(AlertType.INFORMATION, ""); alert.initModality(Modality.APPLICATION_MODAL); alert.initOwner(mainStage); alert.getDialogPane().setContentText("你的帐号在其他的地方登录!"); alert.getDialogPane().setHeaderText(null); return alert; }
Example 18
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 19
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); }
Example 20
Source File: AbstractChartMeasurement.java From chart-fx with Apache License 2.0 | 4 votes |
public AbstractChartMeasurement(final ParameterMeasurements plugin, final String measurementName, final AxisMode axisMode, final int requiredNumberOfIndicators, final int requiredNumberOfDataSets) { if (plugin == null) { throw new IllegalArgumentException("plugin is null"); } this.plugin = plugin; this.measurementName = measurementName; this.axisMode = axisMode; this.requiredNumberOfIndicators = requiredNumberOfIndicators; this.requiredNumberOfDataSets = requiredNumberOfDataSets; plugin.getChartMeasurements().add(this); alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Measurement Config Dialog"); alert.setHeaderText("Please, select data set and/or other parameters:"); alert.initModality(Modality.APPLICATION_MODAL); final DecorationPane decorationPane = new DecorationPane(); decorationPane.getChildren().add(gridPane); alert.getDialogPane().setContent(decorationPane); alert.getButtonTypes().setAll(buttonOK, buttonDefault, buttonRemove); alert.setOnCloseRequest(evt -> alert.close()); // add data set selector if necessary (ie. more than one data set available) dataSetSelector = new DataSetSelector(plugin, requiredNumberOfDataSets); if (dataSetSelector.getNumberDataSets() >= 1) { lastLayoutRow = shiftGridPaneRowOffset(dataSetSelector.getChildren(), lastLayoutRow); gridPane.getChildren().addAll(dataSetSelector.getChildren()); } valueIndicatorSelector = new ValueIndicatorSelector(plugin, axisMode, requiredNumberOfIndicators); // NOPMD lastLayoutRow = shiftGridPaneRowOffset(valueIndicatorSelector.getChildren(), lastLayoutRow); gridPane.getChildren().addAll(valueIndicatorSelector.getChildren()); valueField.setMouseTransparent(true); GridPane.setVgrow(dataViewWindow, Priority.NEVER); dataViewWindow.setOnMouseClicked(mouseHandler); getValueIndicatorsUser().addListener(valueIndicatorsUserChangeListener); dataViewWindow.nameProperty().bindBidirectional(title); setTitle(AbstractChartMeasurement.this.getClass().getSimpleName()); // NOPMD dataSet.addListener(dataSetChangeListener); dataSetChangeListener.changed(dataSet, null, null); getMeasurementPlugin().getDataView().getVisibleChildren().add(dataViewWindow); }