本文整理汇总了Java中javafx.scene.control.ComboBox.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java ComboBox.getValue方法的具体用法?Java ComboBox.getValue怎么用?Java ComboBox.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ComboBox
的用法示例。
在下文中一共展示了ComboBox.getValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validationButtonClick
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
@FXML
public void validationButtonClick(Event evt) {
boolean allGood = true;
int count = 0;
while (count < 6 && allGood == true) {
ComboBox action = choiceBoxes.get(count);
if (action.getValue() != null) {
if (action.getValue().equals("Delegation")) {
ComboBox region = regionBoxes.get(count);
if (region.getValue() == null) {
allGood = false;
}
}
} else {
allGood = false;
}
count++;
}
if (allGood) {
validateAndClose(evt);
} else {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Pas de précipitation !");
alert.setHeaderText(null);
alert.setContentText("Vous devez choisir 6 actions !\nNe pas oublier de choisir la région pour les délégations.");
alert.showAndWait();
}
}
示例2: validateAndClose
import javafx.scene.control.ComboBox; //导入方法依赖的package包/类
private void validateAndClose(Event evt) {
for (int i = 0; i < 6; i++) {
ComboBox action = choiceBoxes.get(i);
if (action.getValue().equals("Delegation")) {
ComboBox region = regionBoxes.get(i);
player.addAction(new Action(Action.Type.delegation, (int) region.getValue()));
} else {
System.out.println(action.getId() + " : " + action.getValue());
switch ((String) action.getValue()) {
case "Chemin de pierre":
player.addAction(new Action(Action.Type.stone));
break;
case "Chemin de glace":
player.addAction(new Action(Action.Type.ice));
break;
case "Chemin de terre":
player.addAction(new Action(Action.Type.soil));
break;
case "Troc":
player.addAction(new Action(Action.Type.bartering));
break;
case "Transaction":
player.addAction(new Action(Action.Type.transaction));
break;
case "Offrande":
player.addAction(new Action(Action.Type.offering));
break;
case "Pause":
player.addAction(new Action(Action.Type.pause));
break;
}
}
}
Stage stage = (Stage) ((Node) evt.getSource()).getScene().getWindow();
stage.close();
}
示例3: 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;
}
}