本文整理汇总了Java中com.jfoenix.controls.JFXComboBox类的典型用法代码示例。如果您正苦于以下问题:Java JFXComboBox类的具体用法?Java JFXComboBox怎么用?Java JFXComboBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JFXComboBox类属于com.jfoenix.controls包,在下文中一共展示了JFXComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
ComboBox<String> cmb = new JFXComboBox<>();
new FilteredComboBoxDecorator<>(cmb, FilteredComboBoxDecorator.STARTSWITH_IGNORE_SPACES);
cmb.setItems(FXCollections.observableArrayList(LISTA));
Initializer.getToolBox()
.getServices()
.getConceptService()
.findAllNames()
.thenAccept(names -> {
Platform.runLater(() -> cmb.setItems(FXCollections.observableArrayList(names)));
});
Scene scene = new Scene(new StackPane(cmb));
scene.getStylesheets().addAll(Initializer.getToolBox().getStylesheets());
stage.setScene(scene);
stage.show();
stage.setTitle("Filtered ComboBox");
stage.setWidth(300);
stage.setHeight(300);
}
示例2: addEnum
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
/**
* Add an enumeration of options to a wizard step.
*
* @param fieldName
* @param defaultValue
* is the index of the value in your options array. Can be set <
* 0 to empty the combobox as default.
* @param prompt
* the tooltip to show
* @param options
* your array of options, use a {@link IconLabel} object to add
* icons to your options. Only the text will be selected.
* @return
*/
@SuppressWarnings("unchecked")
public WizardStepBuilder addEnum(final String fieldName, final int defaultValue, final String prompt,
final IconLabel... options)
{
final JFXComboBox<IconLabel> jfxCombo = new JFXComboBox<>();
jfxCombo.getItems().addAll(options);
jfxCombo.setPromptText(prompt);
if (defaultValue < 0)
jfxCombo.setValue(new IconLabel(null, ""));
else
jfxCombo.setValue(options[defaultValue]);
this.current.getData().put(fieldName, new SimpleObjectProperty<IconLabel>());
this.current.getData().get(fieldName).bind(jfxCombo.valueProperty());
final Label label = new Label(fieldName);
GridPane.setHalignment(label, HPos.RIGHT);
GridPane.setHalignment(jfxCombo, HPos.LEFT);
this.current.add(label, 0, this.current.getData().size() - 1);
this.current.add(jfxCombo, 1, this.current.getData().size() - 1);
return this;
}
示例3: setUpCrewGender
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public void setUpCrewGender() {
String s[] = new String[SIZE_OF_CREW];
for (int j = 0; j < SIZE_OF_CREW; j++) {
GenderType n = personConfig.getConfiguredPersonGender(j, ALPHA_CREW);
// convert MALE to M, FEMAL to F
s[j] = n.toString();
if (s[j].equals("MALE"))
s[j] = "M";
else
s[j] = "F";
JFXComboBox<String> g = setUpCB(GENDER_ROW, j); // 2 = Gender
// g.setMaximumRowCount(2);
gridPane.add(g, j + 1, GENDER_ROW); // gender's row = 2
// genderOListComboBox.add(g);
g.setValue(s[j]);
genderList.add(j, g);
}
}
示例4: setUpCountryCB
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public JFXComboBox<String> setUpCountryCB(int index) {
List<String> countries = personConfig.createCountryList();
Collections.sort(countries);
ObservableList<String> countryOList = FXCollections.observableArrayList(countries);
JFXComboBox<String> cb = new JFXComboBox<String>(countryOList);
/*
ValidationSupport vs = new ValidationSupport();
vs.registerValidator(cb, Validator.createEmptyValidator( "ComboBox Selection required"));
vs.validationResultProperty().addListener( (o, oldValue, newValue) -> {
//Collection<?> c
boolean b = o.getValue().getMessages().contains("ComboBox Selection required");
if (b)
System.out.println("Missing ComboBox Selection(s) for country in Crew Editor. Please double check!");
//if (o.getValue() == null || o.getValue().equals(""))
// System.out.println("invalid choice of country of origin !");
}
);
*/
return cb;
}
示例5: createFXSettlementComboBox
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public void createFXSettlementComboBox() {
sBox = new JFXComboBox<>();
// sBox.setAlignment(Pos.CENTER_RIGHT);
// JFXListView<Settlement> list = new JFXListView<Settlement>();
sBox.getStyleClass().add("jfx-combo-box");
setQuickToolTip(sBox, Msg.getString("SettlementWindow.tooltip.selectSettlement")); //$NON-NLS-1$
// ObservableList<Settlement> names = sim.getUnitManager().getSettlementOList();
sBox.itemsProperty().setValue(sim.getUnitManager().getSettlementOList());
sBox.setPromptText("Select a settlement to view");
sBox.getSelectionModel().selectFirst();
sBox.valueProperty().addListener((observable, oldValue, newValue) -> {
if (oldValue != newValue) {
SwingUtilities.invokeLater(() -> mapPanel.setSettlement((Settlement) newValue));
}
});
settlementBox = new StackPane(sBox);
settlementBox.setMaxSize(180, 30);
settlementBox.setPrefSize(180, 30);
settlementBox.setAlignment(Pos.CENTER_RIGHT);
}
示例6: getComboBox
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public ComboBox<String> getComboBox() {
if (comboBox == null) {
comboBox = new JFXComboBox<>();
new FilteredComboBoxDecorator<>(comboBox,
FilteredComboBoxDecorator.STARTSWITH_IGNORE_SPACES);
}
return comboBox;
}
示例7: getComboBox
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public ComboBox<ImageReference> getComboBox() {
if (comboBox == null) {
comboBox = new JFXComboBox<>();
comboBox.setCellFactory(param -> new ListCell<ImageReference>() {
@Override
protected void updateItem(ImageReference item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
}
else {
String text = item.getDescription() + " [" + item.getFormat() + "]";
setText(text);
}
}
});
comboBox.setConverter(new StringConverter<ImageReference>() {
@Override
public String toString(ImageReference object) {
return object.getDescription() + " [" + object.getFormat() + "]";
}
@Override
public ImageReference fromString(String string) {
return null;
}
});
comboBox.getSelectionModel()
.selectedItemProperty()
.addListener((obs, oldv, newv) -> {
Image image = newv == null ? null : new Image(newv.getUrl().toExternalForm());
getImageView().setImage(image);
});
comboBox.setMaxWidth(Double.MAX_VALUE);
//comboBox.setEditable(false);
}
return comboBox;
}
示例8: setup
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
private void setup() {
GridPane grid = new GridPane();
grid.setPadding(new Insets(8));
HBox row = new HBox(8);
row.setAlignment(Pos.CENTER);
Label databaseTypeLabel = new Label("Database type");
ComboBox<DatabaseType> databaseTypeField = new JFXComboBox<>();
databaseTypeField.getItems().addAll(DatabaseType.values());
row.getChildren().addAll(databaseTypeLabel, databaseTypeField);
Button loginButton = new RaisedButton("Login");
loginButton.setOnAction((ActionEvent click) -> {
StorageOptions options = form.onConfirm();
controller.startupManageView(options);
});
databaseTypeField.valueProperty().addListener(change -> {
DatabaseType selected = databaseTypeField.getValue();
if (selected == null) {
return;
}
changeForm(selected, grid);
});
databaseTypeField.valueProperty().setValue(databaseTypeField.getItems().get(0));
getChildren().addAll(row, grid, loginButton);
}
示例9: setUpGenderCB
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public JFXComboBox<String> setUpGenderCB(int index) {
// List<String> genderList = new ArrayList<String>(2);
// genderList.add("M");
// genderList.add("F");
List<String> genderList = Arrays.asList("M", "F");
ObservableList<String> genderOList = FXCollections.observableArrayList(genderList);
JFXComboBox<String> cb = new JFXComboBox<String>(genderOList);
//genderCBs.add(index, cb);
return cb;
}
示例10: setUpJobCB
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public JFXComboBox<String> setUpJobCB(int index) {
/*
* ObservableList<String> options = FXCollections.observableArrayList(
* "Option 1", "Option 2", "Option 3" ); final ComboBox comboBox = new
* ComboBox(options);
*/
List<String> jobs = new ArrayList<String>(15);
jobs.add("Architect");
jobs.add("Areologist");
jobs.add("Astronomer");
jobs.add("Biologist");
jobs.add("Botanist");
jobs.add("Chef");
jobs.add("Chemist");
jobs.add("Doctor");
jobs.add("Driver");
jobs.add("Engineer");
// jobs.add("Manager");
jobs.add("Mathematician");
jobs.add("Meteorologist");
jobs.add("Physicist");
jobs.add("Technician");
jobs.add("Trader");
Collections.sort(jobs);
ObservableList<String> jobsOList = FXCollections.observableArrayList(jobs);
JFXComboBox<String> cb = new JFXComboBox<String>(jobsOList);
//jobCBs.add(index, cb);
return cb;
// AutoCompleteJFXComboBox<String> jobsACCB = new
// AutoCompleteComboBox<>(FXCollections.observableArrayList(jobs));
// FilterJFXComboBox<String> jobsFCB = new
// FilterComboBox<>(FXCollections.observableArrayList(jobs));
// return jobsFCB;
}
示例11: setUpCrewJob
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public void setUpCrewJob() {
String n[] = new String[SIZE_OF_CREW];
for (int i = 0; i < SIZE_OF_CREW; i++) {
n[i] = personConfig.getConfiguredPersonJob(i, ALPHA_CREW);
JFXComboBox<String> g = setUpCB(JOB_ROW, i); // 3 = Job
// g.setMaximumRowCount(8);
gridPane.add(g, i + 1, JOB_ROW); // job's row = 3
g.setValue(n[i]);
jobList.add(i, g);
}
}
示例12: setUpCrewSponsor
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public void setUpCrewSponsor() {
String n[] = new String[SIZE_OF_CREW];
for (int i = 0; i < SIZE_OF_CREW; i++) {
n[i] = personConfig.getConfiguredPersonSponsor(i, ALPHA_CREW);
JFXComboBox<String> g = setUpCB(SPONSOR_ROW, i); // 4 = sponsor
// g.setMaximumRowCount(8);
gridPane.add(g, i + 1, SPONSOR_ROW); // sponsor's row = 4
g.setValue(n[i]);
sponsorList.add(i, g);
}
}
示例13: setUpCrewCountry
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public void setUpCrewCountry() {
String n[] = new String[SIZE_OF_CREW];
for (int i = 0; i < SIZE_OF_CREW; i++) {
n[i] = personConfig.getConfiguredPersonCountry(i, ALPHA_CREW);
JFXComboBox<String> g = setUpCB(COUNTRY_ROW, i); // 5 = Country
// g.setMaximumRowCount(8);
gridPane.add(g, i + 1, COUNTRY_ROW); // country's row = 5
g.setValue(n[i]);
countryList.add(i, g);
}
}
示例14: setUpDestinationCB
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
public JFXComboBox<String> setUpDestinationCB() {
setupSettlementNames();
// destinationsOListComboBox = new JFXComboBox<String>(destinationsOList);
destinationsOListComboBox.setItems(destinationsOList);
return destinationsOListComboBox;
}
示例15: start
import com.jfoenix.controls.JFXComboBox; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
JFXComboBox<Label> combo = new JFXComboBox<>();
combo.getItems().add(new Label("Java 1.8"));
combo.getItems().add(new Label("Java 1.7"));
combo.getItems().add(new Label("Java 1.6"));
combo.getItems().add(new Label("Java 1.5"));
combo.setEditable(true);
combo.setPromptText("Select Java Version");
combo.setConverter(new StringConverter<Label>() {
@Override
public String toString(Label object) {
return object==null? "" : object.getText();
}
@Override
public Label fromString(String string) {
return new Label(string);
}
});
HBox pane = new HBox(100);
HBox.setMargin(combo, new Insets(20));
pane.setStyle("-fx-background-color:WHITE");
pane.getChildren().add(combo);
final Scene scene = new Scene(pane, 300, 300);
scene.getStylesheets().add(ComboBoxDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
primaryStage.setTitle("JFX ComboBox Demo");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}