當前位置: 首頁>>代碼示例>>Java>>正文


Java ComboBox.setValue方法代碼示例

本文整理匯總了Java中javafx.scene.control.ComboBox.setValue方法的典型用法代碼示例。如果您正苦於以下問題:Java ComboBox.setValue方法的具體用法?Java ComboBox.setValue怎麽用?Java ComboBox.setValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.ComboBox的用法示例。


在下文中一共展示了ComboBox.setValue方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createLanguageSelector

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
private Node createLanguageSelector () {
    ObservableList<Locale> locales = FXCollections
            .observableArrayList(LocaleManager.getInstance().getSupportedLocales());
    ComboBox<Locale> selector = new ComboBox<>(locales);
    new BasicUIFactory().addStyling(selector, "LangSelect");
    selector.setValue(LocaleManager.getInstance().getCurrentLocaleProperty().get());
    selector.valueProperty().addListener(event -> updateLocale(selector));
    return selector;
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:10,代碼來源:MainUserInterface.java

示例2: getControlPanel

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
@Override
public Node getControlPanel() {
    VBox box = new VBox();

    ComboBox<CellType> comboBox = new ComboBox<>();
    comboBox.getItems().addAll(CellType.values());
    comboBox.setValue(CellType.STANDARD);
    comboBox.valueProperty().addListener(it -> {
        switch (comboBox.getValue()) {
            case USAGE:
                monthView.setCellFactory(param -> new MonthSheetView.UsageDateCell(param.getView(), param.getDate()));
                break;
            case BADGE:
                monthView.setCellFactory(param -> new MonthSheetView.BadgeDateCell(param.getView(), param.getDate()));
                break;
            case DETAILED:
                monthView.setCellFactory(param -> new MonthSheetView.DetailedDateCell(param.getView(), param.getDate()));
                break;
            case STANDARD:
                monthView.setCellFactory(param -> new MonthSheetView.SimpleDateCell(param.getView(), param.getDate()));
                break;
        }
    });

    box.getChildren().add(comboBox);
    final CalendarPropertySheet propertySheet = new CalendarPropertySheet(monthView.getPropertySheetItems());
    VBox.setVgrow(propertySheet, Priority.ALWAYS);
    box.getChildren().add(propertySheet);

    return box;
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:32,代碼來源:HelloMonthSheetView.java

示例3: getGroupIdentifier

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public Optional<SecretsGroupIdentifier> getGroupIdentifier() {
    Stage dialog = new Stage();
    dialog.initModality(Modality.WINDOW_MODAL);
    dialog.initOwner(parent);
    dialog.initStyle(StageStyle.UTILITY);

    VBox layout = new VBox();
    Label label = new Label("Create Secrets Group");

    Text nameLabel = new Text("Name:");
    TextField name = new TextField();
    HBox n = new HBox();
    n.getChildren().addAll(nameLabel, name);

    ObservableList<Region> regions =
            FXCollections.observableArrayList(Region.values());

    Text regionLabel = new Text("Region:");
    ComboBox<Region> region = new ComboBox<>(regions);
    region.setValue(defaultRegion);


    HBox r = new HBox();
    r.getChildren().addAll(regionLabel, region);

    HBox actions = new HBox();
    Button create = new Button("Create");
    Button cancel = new Button("Cancel");
    actions.getChildren().addAll(create, cancel);

    create.setOnAction(f -> {
        if (name.getText() != null) {
            secretsGroupIdentifier = Optional.of(new SecretsGroupIdentifier(region.getValue(), name.getText()));
        }
        dialog.close();
    });

    cancel.setOnAction(f -> {
        dialog.close();
    });

    layout.getChildren().addAll(label, n, r, actions);

    Scene scene2 = new Scene(layout, 370, 250);
    dialog.setScene(scene2);

    dialog.showAndWait();


    return secretsGroupIdentifier;
}
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:52,代碼來源:GetGroupIdentifier.java

示例4: create

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public static <T extends Enum<T>> ComboBox<T> create(Class<T> enumType, T defaultEnumValue) {

        List<T> entries = new ArrayList<>();
        Collections.addAll(entries, enumType.getEnumConstants());

        ObservableList<T> observableList = FXCollections.observableList(entries);
        ComboBox<T> comboBox = new ComboBox<T>(observableList);
        comboBox.setValue(defaultEnumValue);

        return comboBox;
    }
 
開發者ID:schibsted,項目名稱:strongbox,代碼行數:12,代碼來源:EnumComboBox.java

示例5: createComboBox

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
private ComboBox<String> createComboBox(){
	final ComboBox<String> languageComboBox = new ComboBox<String>();
	String number = resources.getString("languageNumber");
	int n = number.charAt(0)-'0';
	for(int i = 0 ; i < n; i++){
		languageComboBox.getItems().add(resources.getString("language" + (i + 1)));
	}
	//default language
	languageComboBox.setValue("English");
	return languageComboBox;
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:12,代碼來源:PasswordManager.java

示例6: showFileMovableDialog

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public Pair<FileAction, String[]> showFileMovableDialog(String bucket, String key, boolean setKey) {
	MainWindowController main = MainWindowController.getInstance();
	ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
	Dialog<String[]> dialog = getDialog(ok);

	TextField keyTextField = new TextField();
	keyTextField.setPrefWidth(300);
	keyTextField.setPromptText(Values.FILE_NAME);
	keyTextField.setText(key);
	ComboBox<String> bucketCombo = new ComboBox<String>();
	bucketCombo.getItems().addAll(main.bucketChoiceCombo.getItems());
	bucketCombo.setValue(bucket);
	CheckBox copyasCheckBox = new CheckBox(Values.COPY_AS);
	copyasCheckBox.setSelected(true);

	GridPane grid = getGridPane();
	grid.add(copyasCheckBox, 0, 0, 2, 1);
	grid.add(new Label(Values.BUCKET_NAME), 0, 1);
	grid.add(bucketCombo, 1, 1);
	if (setKey) {
		grid.add(new Label(Values.FILE_NAME), 0, 2);
		grid.add(keyTextField, 1, 2);
		Platform.runLater(() -> keyTextField.requestFocus());
	}

	dialog.getDialogPane().setContent(grid);
	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == ok) {
			return new String[] { bucketCombo.getValue(), keyTextField.getText() };
		}
		return null;
	});

	Optional<String[]> result = dialog.showAndWait();
	if (result.isPresent()) {
		bucket = bucketCombo.getValue();
		key = keyTextField.getText();
		FileAction action = copyasCheckBox.isSelected() ? FileAction.COPY : FileAction.MOVE;
		return new Pair<FileAction, String[]>(action, new String[] { bucket, key });
	} else {
		return null;
	}
}
 
開發者ID:zhazhapan,項目名稱:qiniu,代碼行數:44,代碼來源:Dialogs.java

示例7: showBucketAddableDialog

import javafx.scene.control.ComboBox; //導入方法依賴的package包/類
public void showBucketAddableDialog() {
	ButtonType ok = new ButtonType(Values.OK, ButtonData.OK_DONE);
	Dialog<String[]> dialog = getDialog(ok);

	TextField bucket = new TextField();
	bucket.setPromptText(Values.BUCKET_NAME);
	TextField url = new TextField();
	url.setPromptText(Values.BUCKET_URL);
	// TextField zone = new TextField();
	ComboBox<String> zone = new ComboBox<String>();
	zone.getItems().addAll(Values.BUCKET_NAME_ARRAY);
	zone.setValue(Values.BUCKET_NAME_ARRAY[0]);

	GridPane grid = getGridPane();
	grid.add(new Label(Values.BUCKET_NAME), 0, 0);
	grid.add(bucket, 1, 0);
	grid.add(new Label(Values.BUCKET_URL), 0, 1);
	grid.add(url, 1, 1);
	grid.add(new Label(Values.BUCKET_ZONE_NAME), 0, 2);
	grid.add(zone, 1, 2);

	Node okButton = dialog.getDialogPane().lookupButton(ok);
	okButton.setDisable(true);

	// 監聽文本框的輸入狀態
	bucket.textProperty().addListener((observable, oldValue, newValue) -> {
		okButton.setDisable(newValue.trim().isEmpty() || url.getText().isEmpty());
	});
	url.textProperty().addListener((observable, oldValue, newValue) -> {
		okButton.setDisable(newValue.trim().isEmpty() || bucket.getText().isEmpty());
	});

	dialog.getDialogPane().setContent(grid);

	Platform.runLater(() -> bucket.requestFocus());

	dialog.setResultConverter(dialogButton -> {
		if (dialogButton == ok) {
			return new String[] { bucket.getText(),
					zone.getValue() + " " + (Checker.isHyperLink(url.getText()) ? url.getText() : "example.com") };
		}
		return null;
	});

	Optional<String[]> result = dialog.showAndWait();
	result.ifPresent(res -> {
		logger.info("bucket name: " + res[0] + ", zone name: " + res[1]);
		Platform.runLater(() -> MainWindowController.getInstance().addItem(res[0]));
		QiniuApplication.buckets.put(res[0], res[1]);
		ConfigLoader.writeConfig();
	});
}
 
開發者ID:zhazhapan,項目名稱:qiniu,代碼行數:53,代碼來源:Dialogs.java


注:本文中的javafx.scene.control.ComboBox.setValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。