本文整理汇总了Java中javafx.scene.control.ChoiceDialog类的典型用法代码示例。如果您正苦于以下问题:Java ChoiceDialog类的具体用法?Java ChoiceDialog怎么用?Java ChoiceDialog使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChoiceDialog类属于javafx.scene.control包,在下文中一共展示了ChoiceDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@Override
public DSSPrivateKeyEntry call() throws Exception {
Map<String, DSSPrivateKeyEntry> map = new HashMap<String, DSSPrivateKeyEntry>();
for (DSSPrivateKeyEntry dssPrivateKeyEntry : keys) {
CertificateToken certificate = dssPrivateKeyEntry.getCertificate();
String text = DSSASN1Utils.getHumanReadableName(certificate) + " (" + certificate.getSerialNumber() + ")";
map.put(text, dssPrivateKeyEntry);
}
Set<String> keySet = map.keySet();
ChoiceDialog<String> dialog = new ChoiceDialog<String>(keySet.iterator().next(), keySet);
dialog.setHeaderText("Select your certificate");
Optional<String> result = dialog.showAndWait();
try {
return map.get(result.get());
} catch (NoSuchElementException e) {
return null;
}
}
示例2: apply
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
protected void apply() {
Media media = toolBox.getData().getMedia();
List<Annotation> selected = new ArrayList<>(toolBox.getData().getSelectedAnnotations());
decorator.findReferenceNumberAssociations(media, associationKey)
.thenAccept(as -> {
List<String> refNums = associationToIdentityRefs(as);
Platform.runLater(() -> {
ChoiceDialog<String> dlg = getDialog();
dlg.getItems().clear();
if (!refNums.isEmpty()) {
dlg.getItems().addAll(refNums);
dlg.setSelectedItem(refNums.iterator().next());
Optional<String> integer = dlg.showAndWait();
integer.ifPresent(i -> {
Association a = new Association(associationKey, Association.VALUE_SELF, i);
toolBox.getEventBus()
.send(new CreateAssociationsCmd(a, selected));
});
}
});
});
}
示例3: handleSaveAllMenuItem
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@FXML
private void handleSaveAllMenuItem() {
String entryFormat = ".csv";
String[] choices = {"CSV file .csv", "Ascii table .txt"};
ChoiceDialog<String> dialog = FXMLUtils.showOptionDialog(stage, Arrays.asList(choices), "Choose output format", "Choose output format",
resources.getString("output.format"));
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
entryFormat = result.get();
String coords = stellarObject.getRightAscension() + " " + stellarObject.getDeclination();
File zip = FXMLUtils.showSaveFileChooser(resources.getString("choose.output.file"),
lastSavePath,
"pdr-export-" + entryFormat.split(" ")[0] + "-" + coords,
stage,
new FileChooser.ExtensionFilter("Zip file (*.zip)", "*.zip"));
if (zip != null) {
updateLastSavePath(zip.getParent());
toZip(zip, coords + entryFormat);
}
}
}
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:23,代码来源:PhotometricDataOverviewController.java
示例4: changeLanguage
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@FXML
private void changeLanguage(ActionEvent event) {
List<String> choices = new ArrayList<>();
choices.add("English");
choices.add("Deutsch");
ChoiceDialog<String> dialog = new ChoiceDialog<>("English", choices);
dialog.setTitle(resources.getString("languagedialog.title"));
dialog.setHeaderText(resources.getString("languagedialog.headerText"));
dialog.setContentText(resources.getString("languagedialog.contentText"));
Optional<String> result = dialog.showAndWait();
Locale locale = result.isPresent() && result.get().equals("English") ? new Locale("en", "EN")
: result.isPresent() && result.get().equals("Deutsch") ? new Locale("de", "DE") : resources.getLocale();
if (!resources.getLocale().toString().equals(locale.toString().substring(0, 2))) {
this.resources = ResourceBundle.getBundle("bundles.tddt", locale);
bus.post(new LanguageChangeEvent(resources));
phaseManager.resetPhase();
}
}
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-team-2,代码行数:25,代码来源:RootLayoutController.java
示例5: show
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
void show(Config config) {
try {
List<PcapNetworkInterface> devices = Pcaps.findAllDevs();
List<String> names = devices.stream().map(PcapNetworkInterface::getName).collect(Collectors.toList());
ChoiceDialog<String> dialog = new ChoiceDialog<>(names.get(0), names);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.setResizable(false);
dialog.setHeaderText("Choose a network interface:");
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
config.setDevice(dialog.getSelectedItem());
MainWindow app = new MainWindow("Knitcap");
app.start(config);
}
} catch (PcapNativeException e) {
e.printStackTrace();
}
}
示例6: removeFiles
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@FXML protected void removeFiles(ActionEvent event) {
ChoiceDialog<File> dialog = new ChoiceDialog<>(new File(DEFAULT_OPTION), importedSounds);
dialog.setTitle("Delete Sample");
dialog.setHeaderText("Choose what sample you would like to delete");
dialog.setContentText("Sample:");
Optional<File> result = dialog.showAndWait();
result.ifPresent(file -> {
if (!file.toString().equals(DEFAULT_OPTION)) {
importedSounds.remove(file);
message.setText(file.getName() + " was removed.");
}
});
event.consume();
}
示例7: askForBabySteps
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
public String askForBabySteps() {
List<String> Optionen = new ArrayList<>();
Optionen.add("Keine BabySteps aktivieren");
Optionen.add("1:00 Minuten");
Optionen.add("2:00 Minuten");
Optionen.add("2:30 Minuten");
Optionen.add("3:00 Minuten");
Optionen.add("4:00 Minuten");
ChoiceDialog<String> dialog = new ChoiceDialog<>("Keine BabySteps aktivieren", Optionen);
dialog.setTitle("BabySteps");
dialog.setHeaderText("M" + "\u00F6" + "chtest du BabySteps aktivieren ?\n" +
"Bei BabySteps wird die Zeit zum Code Schreiben limitiert.");
dialog.setContentText("Bitte w" + "\u00E4" + "hle deine gew" + "\u00FC" + "nschte Zeit:");
Optional<String> Auswahl = dialog.showAndWait();
if (Auswahl.isPresent()) {
return Auswahl.get();
}
return "";
}
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-halt-doch-einfach-mal-dein-maul,代码行数:20,代码来源:WarningUnit.java
示例8: selectOwnVersion
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
/**
* Öffnet einen Dialog, in dem der Spieler auswählen kann,
* zu welcher KI die hochzuladende Version hinzugefügt werden soll.
*
* @return
*/
public static AiBase selectOwnVersion() {
if (MainApp.ownOnlineAis == null)
return null;
ObservableList<AiBase> list = FXCollections.observableArrayList();
list.addAll(MainApp.ownOnlineAis);
list.add(new AiFake());
ChoiceDialog<AiBase> dialog = new ChoiceDialog<>();
dialog.getItems().addAll(list);
dialog.setSelectedItem(list.get(0));
dialog.setTitle("Version hochladen");
dialog.setHeaderText("Wähle bitte eine KI aus, zu dem die Version hochgeladen werden soll.");
dialog.setContentText("KI:");
Optional<AiBase> result = dialog.showAndWait();
if (result.isPresent()) {
return result.get();
}
return null;
}
示例9: handleScriptsButtonAction
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@FXML
public void handleScriptsButtonAction() {
final ChoiceDialog<String> dialog = new ChoiceDialog<>(null, model.getScripts());
dialog.initOwner(application.getPrimaryStage());
dialog.setTitle("Scripts");
dialog.setHeaderText("Select script to run");
dialog.setContentText("Script:");
dialog.setSelectedItem(model.getLastRunnedScript());
final Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
try {
model.runScript(result.get());
} catch (final IllegalAccessException e) {
logger.warning(e.getMessage());
}
}
}
示例10: showSelectionDialog
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@Override
public String showSelectionDialog(final Widget widget, final String title, final List<String> options)
{
final Node node = JFXBaseRepresentation.getJFXNode(widget);
final CompletableFuture<String> done = new CompletableFuture<>();
execute( ()->
{
final ChoiceDialog<String> dialog = new ChoiceDialog<>(null, options);
DialogHelper.positionDialog(dialog, node, -100, -50);
dialog.setHeaderText(title);
final Optional<String> result = dialog.showAndWait();
done.complete(result.orElse(null));
});
try
{
return done.get();
}
catch (Exception ex)
{
logger.log(Level.WARNING, "Selection dialog ('" + title + ", ..') failed", ex);
}
return null;
}
示例11: pickStylerToConfigure
import javafx.scene.control.ChoiceDialog; //导入依赖的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);
}
}
示例12: newGame
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@FXML
public void newGame(){
ChoiceDialog<Integer> dialog = new ChoiceDialog<>(viewModel.sizeProperty().get(), viewModel.getSizeOptions());
dialog.setTitle("New Game");
dialog.setHeaderText("Start a new Game");
dialog.setContentText("Choose the size:");
Optional<Integer> result = dialog.showAndWait();
result.ifPresent(size->{
viewModel.sizeProperty().set(size);
final ViewTuple<PuzzleView, PuzzleViewModel> viewTuple = FluentViewLoader.fxmlView(PuzzleView.class).load();
final Parent view = viewTuple.getView();
center.setMinSize(0,0);
center.setPrefSize(0,0);
if(view instanceof Region){
center.setContent((Region) view);
}
});
}
示例13: showOptionsMessage
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
/**
* @param parent
* dialog parent, if null default parent is used
* @param message
* Question message to show
* @param choices
* possible choices where {@link Pair} value is the choice label displayed
* @return selected choice or null if canceled
* @param <T>
* choice type
*/
public static <T> T showOptionsMessage(final Window parent, final String message,
final Collection<Pair<T, String>> choices)
{
final List<ChoiceWrapper<T>> choiceWrapper = choices.stream()
.map((c) -> new ChoiceWrapper<T>(c.getKey(), c.getValue()))
.collect(Collectors.toList());
final ChoiceDialog<ChoiceWrapper<T>> dialog = new ChoiceDialog<ChoiceWrapper<T>>(choiceWrapper.get(0),
choiceWrapper);
initDialog(parent, dialog);
dialog.setContentText(message);
dialog.showAndWait();
final ChoiceWrapper<T> result = dialog.getResult();
return (result != null ? result.getValue() : null);
}
示例14: filter
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
@Override public List<String> filter(List<String> values) {
List<String> ret = new LinkedList<>();
//when there is only one file, select it. when there is no file, also don't
//show a dialog.
if (values.size() < 2) {
ret.addAll(values);
}
else {
ChoiceDialog<String> dialog = new ChoiceDialog<>(values.get(0), values); //TODO: use Zong! dialog factory
dialog.setContentText(Lang.getLabel(Voc.SelectDocument));
Optional<String> selectedFile = dialog.showAndWait();
//open file
selectedFile.ifPresent(ret::add);
}
return ret;
}
示例15: initializeChoiceDialog
import javafx.scene.control.ChoiceDialog; //导入依赖的package包/类
private void initializeChoiceDialog() {
newSaveFileDialog = new ChoiceDialog<>(null, playerGames);
newSaveFileDialog.setTitle("Save file");
newSaveFileDialog.setHeaderText("I see you played your turn");
((Stage) newSaveFileDialog.getDialogPane().getScene().getWindow()).setAlwaysOnTop(true);
newSaveFileDialog.setContentText("Choose the game you would to submit to GMR");
}