Java Examples for javafx.collections.FXCollections.observableArrayList
The following java examples will help you to understand the usage of javafx.collections.FXCollections.observableArrayList. These source code samples are taken from different open source projects.
Example 1
| Project: sandboxes-master File: ButtonAreaOutOfSyncWithSelectionModel.java View source code |
@Override
public void start(Stage stage) {
FlowPane pane = new FlowPane();
final ComboBox<String> comboBox = new ComboBox<>();
comboBox.setPrefWidth(500);
comboBox.setItems(observableArrayList("one", "two"));
comboBox.setPromptText("juhu");
pane.getChildren().add(comboBox);
final Label selectedItemLabel = new Label("false");
pane.getChildren().add(selectedItemLabel);
stage.setScene(new Scene(pane));
stage.show();
comboBox.getSelectionModel().select("two");
comboBox.setItems(observableArrayList("three", "four"));
selectedItemLabel.setText("selected item: " + comboBox.getSelectionModel().selectedItemProperty().get());
}Example 2
| Project: speedment-master File: NullableItem.java View source code |
@Override
protected Node createUndecoratedEditor() {
final CheckBox cbNull = new CheckBox();
final Node wrappedCb = ItemUtil.lockDecorator(cbNull, ItemUtil.DATABASE_RELATION_TOOLTIP);
final Label label = new Label(IMPLEMENTATION_TITLE);
final ChoiceBox<ImplementAs> cbImpl = new ChoiceBox<>(observableArrayList(ImplementAs.values()));
cbImpl.setTooltip(new Tooltip(IMPLEMENTATION_TOOLTIP));
final HBox right = new HBox(label, cbImpl);
final HBox left = new HBox(wrappedCb, right);
left.setSpacing(16);
right.setSpacing(8);
right.setAlignment(Pos.CENTER);
cbNull.selectedProperty().bindBidirectional(nullable);
cbImpl.valueProperty().bindBidirectional(implementation);
right.visibleProperty().bind(nullable);
right.disableProperty().bind(nullable.not());
return left;
}Example 3
| Project: griffon-master File: ElementObservableListTest.java View source code |
@Test
public void testOperations() {
// given:
ObservableList<ObservablePerson> source = observableArrayList();
ObservableList<ObservablePerson> target = new ElementObservableList<>(source);
final AtomicBoolean changed = new AtomicBoolean(false);
ListChangeListener<ObservablePerson> listener = c -> changed.set(true);
target.addListener(listener);
// when:
ObservablePerson person = new ObservablePerson(1, "Andres", "Almiray");
source.add(person);
// then:
assertTrue(changed.get());
// when:
changed.set(false);
person.setLastname("Jaramillo");
// then:
assertTrue(changed.get());
// when:
source.remove(person);
changed.set(false);
person.setLastname("Almiray");
// then:
assertFalse(changed.get());
}Example 4
| Project: Zong-master File: AudioSettingsDialog.java View source code |
public void initialize() {
//fill device names and select default value
List<String> deviceNames = SynthManager.getAudioMixers();
deviceNames.add(0, Lang.get(Voc.Default));
cmbDeviceName.setItems(observableArrayList(deviceNames));
cmbDeviceName.getSelectionModel().select(0);
//fill other settings
cmbSampleRateHz.setItems(observableArrayList("11025", "22050", "44100"));
cmbSampleRateHz.getSelectionModel().select(2);
cmbChannels.setItems(observableArrayList("1", "2"));
cmbChannels.getSelectionModel().select(1);
cmbBits.setItems(observableArrayList("8", "16"));
cmbBits.getSelectionModel().select(1);
cmbLatencyMs.setItems(observableArrayList("100", "200", "400", "800"));
cmbLatencyMs.getSelectionModel().select(0);
cmbMaxPolyphony.setItems(observableArrayList("32", "64", "96", "128", "256"));
cmbMaxPolyphony.getSelectionModel().select(1);
cmbInterpolation.setItems(observableArrayList(Lang.get(Voc.Linear), Lang.get(Voc.Cubic), Lang.get(Voc.Sinc), Lang.get(Voc.Point)));
cmbInterpolation.getSelectionModel().select(0);
//fill with current values, if available
Settings s = Settings.getInstance();
String file = SynthManager.configFile;
setValue(cmbDeviceName, s.getSetting("devicename", file));
setValue(cmbSampleRateHz, s.getSetting("samplerate", file));
setValue(cmbChannels, s.getSetting("channels", file));
setValue(cmbBits, s.getSetting("bits", file));
setValue(cmbLatencyMs, s.getSetting("latency", file));
setValue(cmbMaxPolyphony, s.getSetting("polyphony", file));
setValue(cmbInterpolation, s.getSetting("interpolation", file));
String soundbank = s.getSetting("soundbank", file);
if (soundbank != null && soundbank.length() > 0) {
try {
File soundbankFile = new File(soundbank);
if (soundbankFile.exists()) {
soundbankPath = soundbankFile.getAbsolutePath();
lblSoundbank.setText(soundbankFile.getName());
}
} catch (Exception ex) {
}
}
}Example 5
| Project: jOOQ-master File: BarChartSample.java View source code |
private BarChart<String, Number> chartRefresh(BarChart<String, Number> bc) {
TableField<CountriesRecord, Number> field = (TableField<CountriesRecord, Number>) bc.getUserData();
bc.getData().clear();
bc.getData().addAll(// -------------------------------------------------
ctx().select(COUNTRIES.YEAR, COUNTRIES.CODE, field).from(COUNTRIES).join(DSL.table(select(COUNTRIES.CODE, avg(field).as("avg")).from(COUNTRIES).groupBy(COUNTRIES.CODE)).as("c1")).on(COUNTRIES.CODE.eq(field(name("c1", COUNTRIES.CODE.getName()), String.class))).orderBy(field(name("avg")), COUNTRIES.CODE, COUNTRIES.YEAR).fetchGroups(// Group results by year, keeping sort order in place
COUNTRIES.YEAR).entrySet().stream().map(// Map each entry into a { Year -> Projected value } series
entry -> new XYChart.Series<>(entry.getKey().toString(), observableArrayList(entry.getValue().map( country -> new XYChart.Data<String, Number>(country.get(COUNTRIES.CODE), country.get(field)))))).collect(toList()));
// If you're using PostgreSQL any commercial database, you could have
// also taken advantage of window functions, which would have greatly
// simplified the above SQL query:
ctx().select(COUNTRIES.YEAR, COUNTRIES.CODE, field).from(COUNTRIES).orderBy(DSL.avg(field).over(partitionBy(COUNTRIES.CODE)), COUNTRIES.CODE, COUNTRIES.YEAR);
return bc;
}