Java Code Examples for javafx.scene.control.ChoiceDialog#setHeaderText()
The following examples show how to use
javafx.scene.control.ChoiceDialog#setHeaderText() .
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: MarsNode.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public Button createGreenhouseDialog(Farming farm) { String name = farm.getBuilding().getNickName(); Button b = new Button(name); b.setMaxWidth(Double.MAX_VALUE); List<String> choices = new ArrayList<>(); choices.add("Lettuce"); choices.add("Green Peas"); choices.add("Carrot"); ChoiceDialog<String> dialog = new ChoiceDialog<>("List of Crops", choices); dialog.setTitle(name); dialog.setHeaderText("Plant a Crop"); dialog.setContentText("Choose Your Crop:"); dialog.initOwner(stage); // post the same icon from stage dialog.initStyle(StageStyle.UTILITY); //dialog.initModality(Modality.NONE); b.setPadding(new Insets(20)); b.setId("settlement-node"); b.getStylesheets().add("/fxui/css/settlementnode.css"); b.setOnAction(e->{ // The Java 8 way to get the response value (with lambda expression). Optional<String> selected = dialog.showAndWait(); selected.ifPresent(crop -> System.out.println("Crop added to the queue: " + crop)); }); //ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE); //ButtonType buttonTypeOk = new ButtonType("OK", ButtonData.OK_DONE); //dialog.getButtonTypes().setAll(buttonTypeCancel, buttonTypeOk); return b; }