本文整理汇总了Java中javafx.scene.control.ChoiceBox.setItems方法的典型用法代码示例。如果您正苦于以下问题:Java ChoiceBox.setItems方法的具体用法?Java ChoiceBox.setItems怎么用?Java ChoiceBox.setItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ChoiceBox
的用法示例。
在下文中一共展示了ChoiceBox.setItems方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ObjectPropertyValueSetter
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
public ObjectPropertyValueSetter(Property listeningProperty, BindingType btype, Object testedControl, List values) {
try {
ChoiceBox cb = new ChoiceBox();
cb.setMaxWidth(175.0);
cb.setId(createId(listeningProperty, btype));
cb.setItems(FXCollections.observableArrayList(values));
cb.getSelectionModel().selectFirst();
leadingControl = cb;
this.leadingProperty = cb.valueProperty();
this.listeningProperty = listeningProperty;
propertyValueType = PropertyValueType.OBJECTENUM;
initialValue1 = !values.isEmpty() ? values.get(0) : null;
bindComponent(btype, testedControl);
} catch (Throwable ex) {
log(ex);
}
}
示例2: addEnumParameterHBox
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
* creates a {@link javafx.scene.layout.HBox} with the information from the
* learning parameter if it is a {@link TerminationCriteria}
*
* @param param
* @param root
* @param position
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void addEnumParameterHBox(LearningParameter param, GridPane root, int position) {
Label parameterLabel = new Label(param.getName());
ChoiceBox cb = new ChoiceBox();
cb.setItems(FXCollections.observableArrayList(getEnumArrayList((Class<Enum>) param.getClazz())));
cb.setValue(param.getValue());
cb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Enum>() {
public void changed(ObservableValue ov, Enum value, Enum new_value ){
param.setValue(new_value.toString());
}
});
root.add(parameterLabel, 0, position);
root.add(cb, 1, position);
}
示例3: initializePreprocessedCorpusList
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
public final void initializePreprocessedCorpusList(){
preprocessedCorpusList = new ChoiceBox();
UIUtils.setSize(preprocessedCorpusList, Main.columnWidthRIGHT, 24);
preprocessedCorpusList.setItems(AppParameters.dataset.preprocessedCorpusList);
preprocessedCorpusList.valueProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue ov, String t, String t1) {
clearFilterUI();
if(t1 != null){
LogUI.addLogEntry("Loading '"+AppParameters.dataset.id+"' ("+t1+")... ");
AppParameters.dataset.corpus.loadFrequencies(t1);
AppParameters.timeSliceA = 0;
AppParameters.timeSliceB = AppParameters.dataset.corpus.messageDistribution.length;
LogUI.addLogEntry("Done.");
resizeSlider.setMin(0);
resizeSlider.setLowValue(0);
resizeSlider.setMax(AppParameters.dataset.corpus.getLength());
resizeSlider.setHighValue(AppParameters.dataset.corpus.getLength());
}
}
});
}
示例4: start
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
VBox vbox = new VBox();
vbox.setPadding(new Insets(10));
vbox.setAlignment(Pos.CENTER);
vbox.setSpacing(10);
Label label = new Label("Make Yes/No Selection");
ChoiceBox<Pair<String, String>> cb = new ChoiceBox<>();
cb.setItems( Constants.LIST_YES_NO );
cb.setConverter( new PairStringConverter() );
cb.setValue( Constants.PAIR_NO );
Label labelOpt = new Label("Make Yes/No Selection (Optional)");
ChoiceBox<Pair<String, String>> cbOpt = new ChoiceBox<>();
cbOpt.setItems( Constants.LIST_YES_NO_OPT );
cbOpt.setConverter(new PairStringConverter(true) );
cbOpt.setValue( Constants.PAIR_NULL );
Button b = new Button("Save");
b.setOnAction( (evt) ->
System.out.println("Selections - yes/no was '" + cb.getValue() + "' and yes/no/opt was '" + cbOpt.getValue() + "'")
);
vbox.getChildren().addAll(label, cb, labelOpt, cbOpt, b);
Scene scene = new Scene(vbox);
primaryStage.setTitle("Choice Box Demo");
primaryStage.setHeight(200);
primaryStage.setWidth(300);
primaryStage.setScene( scene );
primaryStage.show();
}
示例5: populateDDL
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
private static void populateDDL(ChoiceBox<String> dropDownList, Collection<String> items) {
List<String> list = new ArrayList<>(items);
ObservableList<String> dropDownItems = FXCollections.observableList(list);
dropDownList.setItems(dropDownItems);
}
示例6: drawPlayersSettings
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
* Affiche les réglages concernant le nombre de joueurs
*/
private void drawPlayersSettings() {
GridPane playersSettingsGrid = new GridPane();
ColumnConstraints column1 = new ColumnConstraints(150);
ColumnConstraints column2 = new ColumnConstraints(200);
playersSettingsGrid.getColumnConstraints().setAll(column1, column2);
/**
* Choix du nombre de joueurs
*/
Label nbOfPlayersLabel = new Label("Nombre de joueurs :");
playersSettingsGrid.add(nbOfPlayersLabel, 0, 0);
ChoiceBox<Integer> nbOfPlayersChoiceBox = new ChoiceBox<Integer>();
nbOfPlayersChoiceBox.setPrefWidth(200);
nbOfPlayersChoiceBox.setItems(
FXCollections.observableArrayList(
2,
3,
4
)
);
nbOfPlayersChoiceBox.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
nbOfPlayers = nbOfPlayersChoiceBox.getItems().get((Integer) newValue);
drawPlayersList();
}
});
// Valeur par défaut
nbOfPlayersChoiceBox.setValue(2);
nbOfPlayers = 2;
GridPane.setMargin(nbOfPlayersChoiceBox, new Insets(5, 0, 5, 0));
playersSettingsGrid.add(nbOfPlayersChoiceBox, 1, 0);
playersSettingsGrid.add(playersList, 0, 1, 2, 1);
root.add(playersSettingsGrid, 0, currentIndex++);
Separator playersSettingsSeparator = new Separator();
root.add(playersSettingsSeparator, 0, currentIndex++);
GridPane.setMargin(playersSettingsSeparator, new Insets(5, 0, 5, 0));
}
示例7: addQualitativeMeasureParameterHBox
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
* creates a {@link javafx.scene.layout.HBox} with the information from the
* learning parameter if it is a {@link IQualitativeMeasure}
*
* @param param
* @param root
* @param position
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void addQualitativeMeasureParameterHBox(LearningParameter param, GridPane root, int position) {
Label parameterLabel = new Label(param.getName());
ChoiceBox cb = new ChoiceBox();
cb.setItems(FXCollections.observableArrayList(getEnumArrayList(EQualitativeMeasure.class)));
try{
//this is a bit hacky
//Since the output of param.getValue().toString() has the form [email protected]8723 we take the class name from this
cb.setValue(EQualitativeMeasure.valueOf(param.getValue().toString().substring(param.getValue().toString().lastIndexOf(".") + 1, param.getValue().toString().lastIndexOf("@"))));
}catch(Exception e){
e.printStackTrace();
}
cb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Enum>() {
public void changed(ObservableValue ov, Enum value, Enum new_value ){
switch(new_value.toString().toLowerCase().trim()){
case "accuracy":
param.setValue(new Accuracy());
break;
case "pseudofmeasure":
param.setValue(new PseudoFMeasure());
break;
case "pseudorefmeasure":
param.setValue(new PseudoRefFMeasure());
break;
case "pseudoprecision":
param.setValue(new PseudoPrecision());
break;
case "pseudorefprecision":
param.setValue(new PseudoRefPrecision());
break;
case "pseudorecall":
param.setValue(new PseudoRecall());
break;
case "pseudorefrecall":
param.setValue(new PseudoRefRecall());
break;
case "fmeasure":
param.setValue(new FMeasure());
break;
case "precision":
param.setValue(new Precision());
break;
case "recall":
param.setValue(new Recall());
break;
default:
logger.error("This IQualitativeMeasure does not exist!");
}
}
});
root.add(parameterLabel, 0, position);
root.add(cb, 1, position);
}
示例8: newSourceUI
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
public final void newSourceUI(){
GridPane gridLEFT = new GridPane();
// Labels
Label sourceIdentifierLabel = new Label("Source ID");
UIUtils.setSize(sourceIdentifierLabel, Main.columnWidthLEFT/2, 24);
Label sourceTypeLabel = new Label("Source type");
UIUtils.setSize(sourceTypeLabel, Main.columnWidthLEFT/2, 24);
Label sourceConfigLabel = new Label("Source configuration");
sourceConfigLabel.setAlignment(Pos.CENTER_LEFT);
UIUtils.setSize(sourceConfigLabel, Main.columnWidthLEFT/2, 150);
gridLEFT.add(sourceTypeLabel,0,0);
gridLEFT.add(new Rectangle(0,3),0,1);
gridLEFT.add(sourceIdentifierLabel,0,2);
gridLEFT.add(new Rectangle(0,3),0,3);
gridLEFT.add(sourceConfigLabel,0,4);
// Values
sourceTypeList = new ChoiceBox();
ObservableList<String> list = FXCollections.observableArrayList();
list.add("Twitter");
sourceTypeList.setItems(list);
UIUtils.setSize(sourceTypeList,Main.columnWidthLEFT/2, 24);
newSourceIdentifierField = new TextField();
newSourceIdentifierField.setPromptText("unique identifier");
UIUtils.setSize(newSourceIdentifierField,Main.columnWidthLEFT/2, 24);
configurationTextArea = new TextArea();
configurationTextArea.setText("# This is a configuration file for Twitter\n" +
"# It is formatted as a Java properties file\n" +
"# i.e. a property (key = value) per line \n" +
"OAuthConsumerKey = w9ixmKqezBWtyughn4y7w\n" +
"OAuthConsumerSecret = mQ7L6cfSRPRAdUoiIOSWRYaHBeU5yBTRPGgc8fFdY\n" +
"OAuthAccessToken = 2371904670-XAnOV6XquVDuWzXwwhAvKiZ9T1DI9ziM3r7Cz3s\n" +
"OAuthAccessTokenSecret = wRwJhSq1m7zZeQYeTgivVSZ6H7acsv0KNiznF3StoH4TU");
UIUtils.setSize(configurationTextArea, Main.columnWidthLEFT/2, 150);
gridLEFT.add(sourceTypeList,1,0);
gridLEFT.add(newSourceIdentifierField,1,2);
gridLEFT.add(configurationTextArea,1,4);
HBox importDatasetBOTH = new HBox(5);
importDatasetBOTH.getChildren().addAll(gridLEFT,createNewSourceButton());
grid.add(importDatasetBOTH,0,5);
}
示例9: configure
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
* Configures the settings layout.
*/
protected void configure() {
super.configure();
configureFrom();
configureTo();
// Selecting the percent by default.
grp.selectToggle(grp.getToggles().get(0));
isFrom.addListener((ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean selected) -> {
if (selected) {
RadioButton btn = (RadioButton) grp.getSelectedToggle();
loadContainerByRadio(btn);
toCB.setDisable(true);
toCB.setSelected(true);
} else {
toContainer.getChildren().clear();
toContainer.getChildren().add(toChoice);
toCB.setDisable(false);
}
});
isFrom.set(true);
isFrom.set(false);
/* Repeat Or Reflect */
CheckBox repeatCB = new CheckBox();
repeatCB.selectedProperty().bindBidirectional(isRepeat);
ChoiceBox<RepeatOrReflect> repeatChoice = new ChoiceBox<RepeatOrReflect>();
repeatChoice.disableProperty().bind(repeatCB.selectedProperty().not());
repeatChoice.setItems(RepeatOrReflect.getList());
repeatChoice.getSelectionModel().select(0);
repeatReflect.bind(repeatChoice.getSelectionModel().selectedItemProperty());
this.grid.add(repeatCB, 0, rowIndex);
this.grid.add(new Label("Repeat or Reflect : "), 1, rowIndex);
this.grid.add(repeatChoice, 2, rowIndex);
rowIndex++;
/* Color Stops */
StackPane stopLblPane = new StackPane();
stopLblPane.setAlignment(Pos.TOP_LEFT);
stopLblPane.setPadding(new Insets(5, 0, 0, 0));
stopLblPane.getChildren().add(new Label("Color Stops : "));
colorStopsVB = new VBox();
colorStopsVB.setSpacing(15);
colorStopsVB.getChildren().addAll(getColorStopTemplate(0, 100, 0, -1, "#ffb6c1"), getColorStopTemplate(0, 100, 0, -1, "#ffa500"));
this.grid.add(stopLblPane, 1, rowIndex);
this.grid.add(colorStopsVB, 2, rowIndex);
rowIndex++;
checkForDeleteBtn();
ColumnConstraints c1 = new ColumnConstraints();
c1.setHalignment(HPos.LEFT);
c1.setMinWidth(20);
ColumnConstraints c2 = new ColumnConstraints();
c2.setHalignment(HPos.LEFT);
c2.setMinWidth(110);
this.grid.getColumnConstraints().addAll(c1, c2);
RowConstraints r = new RowConstraints();
r.setValignment(VPos.TOP);
this.grid.getRowConstraints().addAll(r, r, r);
}
示例10: bindSelector
import javafx.scene.control.ChoiceBox; //导入方法依赖的package包/类
/**
* Configures the given selector with the given {@code items}, and binds it to the given properties.
* <p>
* The initial values for the selector and the selectedItem are set based on {@code selectedItemIndexProperty}.
*
* @param selector
* the selector to configure
* @param items
* the items to put in the selector
* @param selectedItemProperty
* the property to bind for the selected item
* @param selectedItemIndexProperty
* the property to bind for the index of the selected item
* @param <T>
* the type of items in the selector
*/
private static <T> void bindSelector(@NotNull ChoiceBox<T> selector, @NotNull ObservableList<T> items,
@NotNull Property<T> selectedItemProperty,
@NotNull IntegerProperty selectedItemIndexProperty) {
selector.setItems(items);
if (!items.isEmpty()) {
int selectedIndex = selectedItemIndexProperty.get();
selectedItemProperty.setValue(items.get(selectedIndex));
selector.getSelectionModel().select(selectedIndex);
}
selectedItemProperty.bindBidirectional(selector.valueProperty());
selectedItemIndexProperty.bind(selector.getSelectionModel().selectedIndexProperty());
}