当前位置: 首页>>代码示例>>Java>>正文


Java ChoiceDialog.setContentText方法代码示例

本文整理汇总了Java中javafx.scene.control.ChoiceDialog.setContentText方法的典型用法代码示例。如果您正苦于以下问题:Java ChoiceDialog.setContentText方法的具体用法?Java ChoiceDialog.setContentText怎么用?Java ChoiceDialog.setContentText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.control.ChoiceDialog的用法示例。


在下文中一共展示了ChoiceDialog.setContentText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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();
}
 
开发者ID:wylliec,项目名称:keymix,代码行数:17,代码来源:Controller.java

示例3: 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

示例4: 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;
}
 
开发者ID:Turnierserver,项目名称:Turnierserver,代码行数:29,代码来源:Dialog.java

示例5: 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());
        }
    }
}
 
开发者ID:paspiz85,项目名称:nanobot,代码行数:18,代码来源:MainController.java

示例6: 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);
        }
    });
}
 
开发者ID:lestard,项目名称:nonogram,代码行数:24,代码来源:MainView.java

示例7: 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);
}
 
开发者ID:ben12,项目名称:reta,代码行数:29,代码来源:MessageDialog.java

示例8: 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;
}
 
开发者ID:Xenoage,项目名称:Zong,代码行数:17,代码来源:FilenameDialogFilter.java

示例9: handleAddItem

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
public void handleAddItem(ActionEvent actionEvent) {
    ChoiceDialog<ChoiceEntry> dialog = new ChoiceDialog<>(null, item_registry);
    dialog.setTitle("Přidat item");
    dialog.setHeaderText("Výběr itemu");
    dialog.setContentText("Vyberte...");
    // Trocha čarování k získání reference na combobox abych ho mohl upravit
    final ComboBox<ChoiceEntry> comboBox = (ComboBox) (((GridPane) dialog.getDialogPane()
        .getContent())
        .getChildren().get(1));
    comboBox.setPrefWidth(100);
    comboBox.setButtonCell(new ChoiceEntryCell());
    comboBox.setCellFactory(param -> new ChoiceEntryCell());
    comboBox.setMinWidth(200);
    comboBox.setMinHeight(40);
    Optional<ChoiceEntry> result = dialog.showAndWait();
    result.ifPresent(choiceEntry -> {
        try {
            final Optional<ItemEntry> entry = items.stream()
                .filter(itemEntry -> itemEntry.getId().equals(choiceEntry.id.get()))
                .findFirst();
            if (!entry.isPresent()) {
                items.add(new ItemEntry(choiceEntry));
            }
        } catch (ItemException e) {
            e.printStackTrace();
        }
    });
}
 
开发者ID:stechy1,项目名称:drd,代码行数:29,代码来源:HeroCreatorController3.java

示例10: showOptionDialog

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
public static ChoiceDialog<String> showOptionDialog(Window owner, List<String> choices,
                                                    String title,
                                                    String header,
                                                    String content) {
    ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
    dialog.setTitle(title);
    dialog.setHeaderText(header);
    dialog.setContentText(content);
    return dialog;
}
 
开发者ID:m-krajcovic,项目名称:photometric-data-retriever,代码行数:11,代码来源:FXMLUtils.java

示例11: actionPerformed

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
/**
 * action to be performed
 *
 * @param ev
 */
public void actionPerformed(ActionEvent ev) {
    final SamplesViewer viewer = (SamplesViewer) getViewer();

    final Collection<String> selected = viewer.getSamplesTable().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 = new Runnable() {
            @Override
            public void run() {
                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();
                if (result.isPresent()) {
                    execute("set nodeShape=" + result.get() + " sample='" + Basic.toString(selected, "' '") + "';");
                }
            }
        };
        if (Platform.isFxApplicationThread())
            runnable.run();
        else
            Platform.runLater(runnable);
    }
}
 
开发者ID:danielhuson,项目名称:megan-ce,代码行数:39,代码来源:SetSampleShapeCommand.java

示例12: getChoiceDialog

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
/**
 * returns the selected Choice of the choices array
 * @param title
 * @param header
 * @param content
 * @return
 */
public static Optional<String> getChoiceDialog(String title, String header, String content) {

	log.info("GetAlert called with: " + title + " - " + header + " - " + content);
	
	ChoiceDialog<String> dialog = new ChoiceDialog<>(choices.get(0), choices);
	dialog.setTitle(title);
	dialog.setHeaderText(header);
	dialog.setContentText(content);

	Optional<String> result = dialog.showAndWait();

	return result;
}
 
开发者ID:timgrossmann,项目名称:StorageSystem,代码行数:21,代码来源:Alerter.java

示例13: clickLetter

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
@FXML protected void clickLetter(ActionEvent event) {
    String id = ((Node)event.getTarget()).idProperty().getValue();

    ChoiceDialog<File> dialog = new ChoiceDialog<>(new File(DEFAULT_OPTION), importedSounds);
    dialog.setTitle("Choose Sample");
    dialog.setHeaderText("Choose what sample you would like to map to letter " + id);
    dialog.setContentText("Sample:");

    Optional<File> result = dialog.showAndWait();
    result.ifPresent(file -> this.mapKey(file, id));

    event.consume();
}
 
开发者ID:wylliec,项目名称:keymix,代码行数:14,代码来源:Controller.java

示例14: showLocaleDialog

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
private void showLocaleDialog(Consumer<String> callback) {
    final String[] localeChoices = localeOptionCache.toArray(new String[localeOptionCache.size()]);
    Arrays.sort(localeChoices);
    ChoiceDialog<String> dialog = new ChoiceDialog<>(localeChoices[0], localeChoices);
    dialog.initOwner(owner);
    dialog.setHeaderText("Choose a Language");
    dialog.setContentText("");
    dialog.show();
    dialog.setOnCloseRequest(evt -> {
        dialog.close();
        dialog.getOwner().requestFocus();
        callback.accept(dialog.getSelectedItem());
    });
}
 
开发者ID:Vogel612,项目名称:TranslationHelper,代码行数:15,代码来源:JFXLocaleChooserController.java

示例15: createGreenhouseDialog

import javafx.scene.control.ChoiceDialog; //导入方法依赖的package包/类
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;
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:34,代码来源:MarsNode.java


注:本文中的javafx.scene.control.ChoiceDialog.setContentText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。