本文整理汇总了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();
}
}