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


Java ChoiceBox.setItems方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:20,代碼來源:ObjectPropertyValueSetter.java

示例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);

   }
 
開發者ID:dice-group,項目名稱:LIMES,代碼行數:24,代碼來源:MachineLearningView.java

示例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());
            }
        }    
    });
}
 
開發者ID:AdrienGuille,項目名稱:SONDY,代碼行數:22,代碼來源:DataManipulationUI.java

示例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();
}
 
開發者ID:bekwam,項目名稱:examples-javafx-repos1,代碼行數:38,代碼來源:ChoiceBoxDemo.java

示例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);
}
 
開發者ID:ciphertechsolutions,項目名稱:IO,代碼行數:6,代碼來源:AdvancedOptionsController.java

示例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));
}
 
開發者ID:ThibaultVlacich,項目名稱:Jeu-des-6-couleurs,代碼行數:54,代碼來源:NewGameWindow.java

示例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);

   }
 
開發者ID:dice-group,項目名稱:LIMES,代碼行數:63,代碼來源:MachineLearningView.java

示例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);
    }
 
開發者ID:AdrienGuille,項目名稱:SONDY,代碼行數:44,代碼來源:DataCollectionUI.java

示例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);

}
 
開發者ID:SaiPradeepDandem,項目名稱:javafx8-gradient-builder,代碼行數:69,代碼來源:LinearSettingsLayout.java

示例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());
}
 
開發者ID:joffrey-bion,項目名稱:fx-log,代碼行數:29,代碼來源:MainController.java


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