本文整理汇总了Java中javafx.scene.control.Dialog.showAndWait方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.showAndWait方法的具体用法?Java Dialog.showAndWait怎么用?Java Dialog.showAndWait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Dialog
的用法示例。
在下文中一共展示了Dialog.showAndWait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: editDocument
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public Optional<String> editDocument(String formattedJson, int cursorPosition) {
Dialog<String> dialog = new Dialog<>();
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
dialog.setTitle("MongoFX - edit document");
dialog.setResizable(true);
dialog.getDialogPane().getStylesheets().add(getClass().getResource("/ui/editor.css").toExternalForm());
CodeArea codeArea = setupEditorArea(formattedJson, dialog, cursorPosition);
dialog.setResultConverter(bt -> {
if (ButtonData.OK_DONE == bt.getButtonData()) {
return codeArea.getText();
}
return null;
});
return dialog.showAndWait();
}
示例2: showAbout
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public void showAbout(ActionEvent actionEvent) throws URISyntaxException {
Dialog<Void> dialog = new Dialog<>();
dialog.setTitle("Tenhou Visualizer について");
dialog.initOwner(this.root.getScene().getWindow());
dialog.getDialogPane().getStylesheets().add(this.getClass().getResource(Main.properties.getProperty("css")).toExternalForm());
dialog.getDialogPane().setGraphic(new ImageView(new Image("/logo.png")));
dialog.getDialogPane().setHeaderText("TenhouVisualizer v0.3");
final Hyperlink oss = new Hyperlink("open-source software");
final URI uri = new URI("https://crazybbb.github.io/tenhou-visualizer/thirdparty");
oss.setOnAction(e -> {
try {
Desktop.getDesktop().browse(uri);
} catch (IOException e1) {
throw new UncheckedIOException(e1);
}
});
dialog.getDialogPane().setContent(new TextFlow(new Label("Powered by "), oss));
dialog.getDialogPane().getButtonTypes().add(ButtonType.CLOSE);
dialog.showAndWait();
}
示例3: showPropertySheet
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* Creates the menu for editing the properties of a widget.
*
* @param tile the tile to pull properties from
* @return the edit property menu
*/
private void showPropertySheet(Tile<?> tile) {
ExtendedPropertySheet propertySheet = new ExtendedPropertySheet();
propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(tile.getContent().titleProperty()));
Dialog<ButtonType> dialog = new Dialog<>();
if (tile.getContent() instanceof Widget) {
((Widget) tile.getContent()).getProperties().stream()
.map(ExtendedPropertySheet.PropertyItem::new)
.forEachOrdered(propertySheet.getItems()::add);
}
dialog.setTitle("Edit widget properties");
dialog.getDialogPane().getStylesheets().setAll(AppPreferences.getInstance().getTheme().getStyleSheets());
dialog.getDialogPane().setContent(new BorderPane(propertySheet));
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);
dialog.showAndWait();
}
示例4: show
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public void show() {
paneController.load();
ResourceBundle i18n = toolBox.getI18nBundle();
Dialog<ButtonType> dialog = new Dialog<>();
dialog.setTitle(i18n.getString("prefsdialog.title"));
dialog.setHeaderText(i18n.getString("prefsdialog.header"));
GlyphsFactory gf = MaterialIconFactory.get();
Text settingsIcon = gf.createIcon(MaterialIcon.SETTINGS, "30px");
dialog.setGraphic(settingsIcon);
dialog.getDialogPane()
.getButtonTypes()
.addAll(ButtonType.OK, ButtonType.CANCEL);
dialog.getDialogPane()
.setContent(paneController.getRoot());
dialog.getDialogPane()
.getStylesheets()
.addAll(toolBox.getStylesheets());
Optional<ButtonType> buttonType = dialog.showAndWait();
buttonType.ifPresent(bt -> {
if (bt == ButtonType.OK) {
paneController.save();
}
});
}
示例5: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Perception-Action Configuration");
dialog.setHeaderText("You can define next action in function of agent perception (up, left, right and down)");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("PerceptionActionAgent.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
PerceptionActionAgentController configurationController = fxmlLoader.getController();
for (PerceptionActionAgentController.PerceptionRule rule : configurationController.tableContent) {
((PerceptionAction) getAlgorithm()).addRule(rule.getLeft(), rule.getRight(), rule.getUp(), rule.getDown(), Directions.valueOf(rule.getAction()));
}
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> s = dialog.showAndWait();
}
示例6: initialize
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
logoImg.setImage(UIUtils.getImage("logo.png"));
Dialog diag = new Dialog();
diag.getDialogPane().setContent(borderPane);
diag.getDialogPane().setBackground(Background.EMPTY);
diag.setResizable(true);
UIUtils.setIcon(diag);
ButtonType closeButton = new ButtonType("Close", ButtonBar.ButtonData.OK_DONE);
diag.getDialogPane().getButtonTypes().addAll(closeButton);
diag.setTitle("About HueSense");
Optional<ButtonType> opt = diag.showAndWait();
if (opt.isPresent() && opt.get().getButtonData() == ButtonBar.ButtonData.OK_DONE) {
// nothing
}
}
示例7: warn
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* Displays a warning dialog with title, message and the options "OK", "Cancel" and "Ignore".
* The given callbacks are run when the respective buttons are pressed.
*
* @param title
* The title to use for the dialog
* @param message
* The message of the dialog
* @param okCallback
* Something to run when the user clicks OK
* @param cancelCallback
* Something to run when the user clicks Cancel
* @param ignoreCallback
* Something to run when the user clicks Ignore
*/
public void warn(String title, String message, Runnable okCallback, Runnable cancelCallback, Runnable ignoreCallback) {
Dialog<ButtonType> d = createBasicDialog(title, message);
d.getDialogPane().getButtonTypes().addAll(OK, CANCEL, IGNORE);
Optional<ButtonType> result = d.showAndWait();
if (result.isPresent()) {
if (result.get() == OK) {
okCallback.run();
} else if (result.get() == CANCEL) {
cancelCallback.run();
} else if (result.get() == IGNORE) {
ignoreCallback.run();
}
}
}
示例8: searchAndChooseCourse
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* Handles search, displaying the found courses for user choice and selecting one of them.
*
* @param input the input string (id or name part)
* @return null if the course wasn't found or the user didn't choose anything
*/
public Course searchAndChooseCourse(String input) {
List<Course> courses = findCourses(input).collect(Collectors.toList());
logger.debug("Courses found for input \"{}\": {}", input, Arrays.toString(courses.toArray()));
if (courses.isEmpty()) {
AlertCreator.showAlert(Alert.AlertType.INFORMATION,
String.format(messages.getString("studyPane.cannotFindCourse"), input));
return null;
}
ChooseCourseController controller = chooseCourseDialogPaneCreator.create(courses);
Dialog<ButtonType> chooseCourseDialog = controller.getDialog();
Optional<ButtonType> result = chooseCourseDialog.showAndWait();
if (result.isPresent() && result.get() == ButtonType.APPLY) {
return controller.getChosenCourse();
} else {
return null;
}
}
示例9: pickStylerToConfigure
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
private void pickStylerToConfigure(final List<Parameterizable> stylers) {
if (stylers.size() == 1) {
selectInCombo(stylers.get(0));
return;
} else if (stylers.isEmpty()) {
selectInCombo(null);
return;
}
List<ParameterizableWrapper> pw = new ArrayList<>(stylers.size());
stylers.stream().forEach((p) -> {
pw.add(new ParameterizableWrapper(p));
});
Dialog<ParameterizableWrapper> dialog = new ChoiceDialog<>(pw.get(0), pw);
ButtonType bt = new ButtonType("choose", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().clear();
dialog.getDialogPane().getButtonTypes().add(bt);
dialog.setTitle("Please choose");
dialog.setHeaderText(null);
dialog.setResizable(true);
dialog.setContentText("choose the styler or condition you want to configure");
Optional<ParameterizableWrapper> choice = dialog.showAndWait();
if (choice.isPresent()) {
selectInCombo(choice.get().p);
}
}
示例10: colorInput
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
@Override
public Optional<Color> colorInput(String action, String question, Color _default) {
Dialog<Color> dialog = new Dialog<>();
dialog.setTitle(action);
dialog.setHeaderText(question);
ColorPicker picker = new ColorPicker(_default);
Button randomiser = new Button("Mix");
randomiser.setOnAction(e -> {
Color current = picker.getValue();
Color shifted = Item.shiftColor(current);
picker.setValue(shifted);
});
HBox box = new HBox();
box.getChildren().addAll(picker, randomiser);
dialog.getDialogPane().setContent(box);
dialog.getDialogPane().getButtonTypes().addAll(
ButtonType.OK, ButtonType.CANCEL);
dialog.setResultConverter(buttonType -> {
if (buttonType.equals(ButtonType.OK)) {
return picker.getValue();
} else {
return null;
}
});
return dialog.showAndWait();
}
示例11: entitySearchDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static <T extends Entity<T>> Optional<List<T>> entitySearchDialog(Query<T> query, boolean multiSelect) {
try {
FXMLLoader loader = new FXMLLoader(EntityGuiController.class.getResource("/fxml/Collection.fxml"));
AnchorPane content = (AnchorPane) loader.load();
final ControllerCollection<T> controller = loader.<ControllerCollection<T>>getController();
controller.setQuery(query, false, false, false, multiSelect);
Dialog<List<T>> dialog = new Dialog<>();
dialog.setHeight(800);
if (multiSelect) {
dialog.setTitle("Choose one or more " + EntityType.singleForClass(query.getEntityType().getType()).getName());
} else {
dialog.setTitle("Choose a " + EntityType.singleForClass(query.getEntityType().getType()).getName());
}
dialog.setResizable(true);
dialog.getDialogPane().setContent(content);
ButtonType buttonTypeOk = new ButtonType("Set", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().add(buttonTypeOk);
ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE);
dialog.getDialogPane().getButtonTypes().add(buttonTypeCancel);
dialog.setResultConverter((ButtonType button) -> {
if (button == buttonTypeOk) {
if (multiSelect) {
return controller.getSelectedEntities();
}
List<T> list = new ArrayList<>();
list.add(controller.getSelectedEntity());
return list;
}
return null;
});
return dialog.showAndWait();
} catch (IOException ex) {
LoggerFactory.getLogger(EntityGuiController.class).error("Failed to load Tab.", ex);
return Optional.empty();
}
}
示例12: showPrefsDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
* Shows a dialog for editing the properties of this tab.
*/
public void showPrefsDialog() {
// Use a flushable property here to prevent a call to populate() on every keystroke in the editor (!)
FlushableProperty<String> flushableSourcePrefix = new FlushableProperty<>(sourcePrefix);
FlushableProperty<Number> flushableTileSize = new FlushableProperty<>(getWidgetPane().tileSizeProperty());
ExtendedPropertySheet propertySheet = new ExtendedPropertySheet(
Arrays.asList(
this.title,
this.autoPopulate,
flushableSourcePrefix,
flushableTileSize,
getWidgetPane().showGridProperty()
));
propertySheet.getItems().addAll(
new ExtendedPropertySheet.PropertyItem<>(getWidgetPane().hgapProperty(), "Horizontal spacing"),
new ExtendedPropertySheet.PropertyItem<>(getWidgetPane().vgapProperty(), "Vertical spacing")
);
Dialog<ButtonType> dialog = new Dialog<>();
dialog.getDialogPane().getStylesheets().setAll(AppPreferences.getInstance().getTheme().getStyleSheets());
dialog.setResizable(true);
dialog.titleProperty().bind(EasyBind.map(this.title, t -> t + " Preferences"));
dialog.getDialogPane().setContent(new BorderPane(propertySheet));
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.CLOSE);
dialog.setOnCloseRequest(__ -> {
flushableSourcePrefix.flush();
flushableTileSize.flush();
});
dialog.showAndWait();
}
示例13: apply
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
protected void apply() {
Dialog<String> dialog = dialogController.getDialog();
dialogController.requestFocus();
Optional<String> opt = dialog.showAndWait();
opt.ifPresent(selectedItem -> {
log.debug("Select upon substrate of " + selectedItem);
Association association = new Association(associationKey,
Association.VALUE_SELF,
selectedItem);
List<Annotation> selectedAnnotations = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
toolBox.getEventBus()
.send(new CreateAssociationsCmd(association, selectedAnnotations));
});
}
示例14: showMessageDialog
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
public static void showMessageDialog(Window window, String title, String message) {
Dialog<ButtonType> dialog = createDialog();
if (window != null) {
dialog.initOwner(window);
}
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
dialog.setTitle(title);
dialog.setContentText(message);
dialog.showAndWait();
}
示例15: showOptions
import javafx.scene.control.Dialog; //导入方法依赖的package包/类
/**
*
*/
@Override
public void showOptions() {
Dialog<String> dialog = new Dialog<>();
dialog.setTitle("Agent Configuration");
dialog.setHeaderText("You can edit: \n - appearance, \n - internal algorithm, \n - objectives, \n - and export and import agents");
dialog.getDialogPane().setPrefSize(500, 600);
FontIcon icon = new FontIcon(FontAwesome.COGS);
icon.setIconSize(64);
dialog.setGraphic(icon);
ButtonType applyChanges = new ButtonType("Apply", ButtonBar.ButtonData.OK_DONE);
dialog.getDialogPane().getButtonTypes().addAll(applyChanges, ButtonType.CANCEL);
try {
FXMLLoader fxmlLoader = new FXMLLoader(ClassLoader.getSystemClassLoader().getResource("MachineLearningAgentConfiguration.fxml"));
Parent root = fxmlLoader.load();
dialog.getDialogPane().setContent(root);
dialog.setResultConverter(dialogButton -> {
if (dialogButton == applyChanges) {
MachineLearningAgentConfigurationController machineLearningConfigurationController = fxmlLoader.getController();
setAlgorithm(machineLearningConfigurationController.getAlgorithm());
return null;
}
return null;
});
} catch (IOException e) {
new ErrorView("No possible load agent configuration");
e.printStackTrace();
}
Optional<String> result = dialog.showAndWait();
}