Java Code Examples for javafx.scene.control.ChoiceDialog#showAndWait()
The following examples show how to use
javafx.scene.control.ChoiceDialog#showAndWait() .
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: TraceAUtilityNetworkController.java From arcgis-runtime-samples-java with Apache License 2.0 | 6 votes |
/** * Prompts the user to select a terminal from a provided list. * * @param terminals a list of terminals for the user to choose from * @return the user's selected terminal */ private Optional<UtilityTerminal> promptForTerminalSelection(List<UtilityTerminal> terminals) { // create a dialog for terminal selection ChoiceDialog<UtilityTerminal> utilityTerminalSelectionDialog = new ChoiceDialog<>(terminals.get(0), terminals); utilityTerminalSelectionDialog.initOwner(mapView.getScene().getWindow()); utilityTerminalSelectionDialog.setTitle("Choose Utility Terminal"); utilityTerminalSelectionDialog.setHeaderText("Junction selected. Choose the Utility Terminal to add as the trace element:"); // override the list cell in the dialog's combo box to show the terminal name @SuppressWarnings("unchecked") ComboBox<UtilityTerminal> comboBox = (ComboBox<UtilityTerminal>) ((GridPane) utilityTerminalSelectionDialog.getDialogPane() .getContent()).getChildren().get(1); comboBox.setCellFactory(param -> new UtilityTerminalListCell()); comboBox.setButtonCell(new UtilityTerminalListCell()); // show the terminal selection dialog and capture the user selection return utilityTerminalSelectionDialog.showAndWait(); }
Example 2
Source File: SetSampleShapeCommand.java From megan-ce with GNU General Public License v3.0 | 5 votes |
/** * action to be performed * * @param ev */ public void actionPerformed(ActionEvent ev) { final SamplesViewer viewer = (SamplesViewer) getViewer(); final Collection<String> selected = viewer.getSamplesTableView().getSelectedSamples(); if (selected.size() > 0) { String sample = selected.iterator().next(); String shapeLabel = viewer.getSampleAttributeTable().getSampleShape(sample); NodeShape nodeShape = NodeShape.valueOfIgnoreCase(shapeLabel); if (nodeShape == null) nodeShape = NodeShape.Oval; final NodeShape nodeShape1 = nodeShape; Runnable runnable = () -> { final ChoiceDialog<NodeShape> dialog = new ChoiceDialog<>(nodeShape1, NodeShape.values()); dialog.setTitle("MEGAN choice"); dialog.setHeaderText("Choose shape to represent sample(s)"); dialog.setContentText("Shape:"); final Optional<NodeShape> result = dialog.showAndWait(); result.ifPresent(shape -> execute("set nodeShape=" + shape + " sample='" + Basic.toString(selected, "' '") + "';")); }; if (Platform.isFxApplicationThread()) runnable.run(); else Platform.runLater(runnable); } }
Example 3
Source File: AddressDialog.java From chat-socket with MIT License | 5 votes |
public void show() { List<String> addresses = NetworkUtils.getAllAddresses(); if (!addresses.isEmpty()) { ChoiceDialog<String> choiceDialog = new ChoiceDialog<>(addresses.get(0), addresses); choiceDialog.setTitle(AppConfig.getDefault().getAppName()); choiceDialog.setHeaderText("Available Addresses"); Optional<String> result = choiceDialog.showAndWait(); if (onSelectedAddress != null && result.isPresent()) onSelectedAddress.call(result.get()); choiceDialog.close(); } }
Example 4
Source File: BatchSetupComponent.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
/** * Load a batch queue from a file. * * @param file the file to read. * @throws ParserConfigurationException if there is a parser problem. * @throws SAXException if there is a SAX problem. * @throws IOException if there is an i/o problem. */ public void loadBatchSteps(final File file) throws ParserConfigurationException, IOException, SAXException { final BatchQueue queue = BatchQueue.loadFromXml( DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file).getDocumentElement()); logger.info("Loaded " + queue.size() + " batch step(s) from " + file.getName()); // Append, prepend, insert or replace. List<QueueOperations> operations = List.of(QueueOperations.values()); ChoiceDialog<QueueOperations> choiceDialog = new ChoiceDialog<>(QueueOperations.Replace, operations); choiceDialog.setTitle("Add Batch Steps"); choiceDialog.setContentText("How should the loaded batch steps be added to the queue?"); choiceDialog.showAndWait(); QueueOperations option = choiceDialog.getResult(); if (option == null) return; int index = currentStepsList.getSelectionModel().getSelectedIndex(); switch (option) { case Replace: index = 0; batchQueue.clear(); batchQueue.addAll(queue); break; case Prepend: index = 0; batchQueue.addAll(0, queue); break; case Insert: index = index < 0 ? 0 : index; batchQueue.addAll(index, queue); break; case Append: index = batchQueue.size(); batchQueue.addAll(queue); break; } selectStep(index); // add to last used files addLastUsedFile(file); }