本文整理匯總了Java中javafx.scene.control.ChoiceBox.setOnAction方法的典型用法代碼示例。如果您正苦於以下問題:Java ChoiceBox.setOnAction方法的具體用法?Java ChoiceBox.setOnAction怎麽用?Java ChoiceBox.setOnAction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.ChoiceBox
的用法示例。
在下文中一共展示了ChoiceBox.setOnAction方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playerConfig
import javafx.scene.control.ChoiceBox; //導入方法依賴的package包/類
/** Creates a new {@code GridPane} for player configuring */
private GridPane playerConfig() {
final GridPane playerGrid = new GridPane();
Label typeText = new Label("Type:");
playerGrid.add(typeText, 0, 0);
ChoiceBox typeSelect = new ChoiceBox();
typeSelect.getItems().addAll("Random", "Rule-based", "Monte Carlo Search");
typeSelect.setOnAction(event -> {
if (typeSelect.valueProperty().get().equals("Monte Carlo Search")) {
// Add additional configurations
Label policyText = new Label("Policy:");
playerGrid.add(policyText, 0, 1);
ChoiceBox policySelect = new ChoiceBox();
policySelect.getItems().addAll("Random", "Rule-based");
playerGrid.add(policySelect, 1, 1);
Label iterNumText = new Label("# of Iters.:");
playerGrid.add(iterNumText, 0, 2);
}
});
return playerGrid;
}
示例2: ifLhs
import javafx.scene.control.ChoiceBox; //導入方法依賴的package包/類
public void ifLhs() {
if (ourOpen instanceof MainController) {
final ChoiceBox<String> searchParams = new ChoiceBox<String>();
searchParams.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
if (((String) searchParams.getValue()).equals("Real Entities")) {
setEntitiesToSearch(EntitiesToSearch.ALL);
} else if (((String) searchParams.getValue()).equals("NPCs")) {
setEntitiesToSearch(EntitiesToSearch.NPC);
} else if (((String) searchParams.getValue()).equals("Gods")) {
setEntitiesToSearch(EntitiesToSearch.GOD);
} else if (((String) searchParams.getValue()).equals("Regions")) {
setEntitiesToSearch(EntitiesToSearch.REGION);
} else if (((String) searchParams.getValue()).equals("Groups")) {
setEntitiesToSearch(EntitiesToSearch.EVENT);
} else if (((String) searchParams.getValue()).equals("Templates")) {
setEntitiesToSearch(EntitiesToSearch.TEMPLATE);
} else if (((String) searchParams.getValue()).equals("Statblocks")) {
setEntitiesToSearch(EntitiesToSearch.STATBLOCK);
}
searchDB();
}
});
searchParams.getItems().add("Real Entities");
searchParams.getItems().add("NPCs");
searchParams.getItems().add("Gods");
searchParams.getItems().add("Regions");
searchParams.getItems().add("Groups");
searchParams.getItems().add("Templates");
searchParams.getItems().add("Statblocks");
searchParams.setPrefWidth(vbox.getPrefWidth());
// cancerous way to reorder the nodes to put search option between search bar and results
// NO JAY DON'T LOOK
List<Node> l = new ArrayList<Node>();
l.add(vbox.getChildren().get(0));
l.add(searchParams);
l.add(vbox.getChildren().get(1));
vbox.getChildren().setAll(l);
l = null;
searchParams.getSelectionModel().select(0);
clearList();
}
}