本文整理匯總了Java中javafx.beans.Observable類的典型用法代碼示例。如果您正苦於以下問題:Java Observable類的具體用法?Java Observable怎麽用?Java Observable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Observable類屬於javafx.beans包,在下文中一共展示了Observable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: bind
import javafx.beans.Observable; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public void bind(final ObjectProperty<?> property, final String propertyName, Class<?> type) {
String value = props.getProperty(propertyName);
if (value != null) {
if (type.getName().equals(Color.class.getName())) {
((ObjectProperty<Color>) property).set(Color.valueOf(value));
} else if (type.getName().equals(String.class.getName())) {
((ObjectProperty<String>) property).set(value);
} else {
((ObjectProperty<Object>) property).set(value);
}
}
property.addListener(new InvalidationListener() {
@Override
public void invalidated(Observable o) {
props.setProperty(propertyName, property.getValue().toString());
}
});
}
示例2: createRadioButton
import javafx.beans.Observable; //導入依賴的package包/類
private RadioButton createRadioButton(final Node rect, String name, final boolean toFront, ToggleGroup tg) {
final RadioButton radioButton = new RadioButton(name);
radioButton.setToggleGroup(tg);
radioButton.selectedProperty().addListener(new InvalidationListener() {
public void invalidated(Observable ov) {
if (radioButton.isSelected()) {
if (toFront) {
rect.toFront();
} else {
rect.toBack();
}
}
}
});
return radioButton;
}
示例3: MonthDayEntriesPane
import javafx.beans.Observable; //導入依賴的package包/類
MonthDayEntriesPane(LocalDate date, int week, int day) {
getStyleClass().add("entries-pane");
this.date = date;
this.week = week;
this.day = day;
entries.addListener((Observable evt) -> update());
setMinSize(0, 0);
setPrefSize(0, 0);
Rectangle clip = new Rectangle();
clip.widthProperty().bind(widthProperty());
clip.heightProperty().bind(heightProperty());
setClip(clip);
moreLabel = new Label();
moreLabel.getStyleClass().add(MONTH_DAY_MORE_LABEL);
moreLabel.setManaged(false);
moreLabel.setVisible(false);
if (getSkinnable().isEnableHyperlinks()) {
moreLabel.getStyleClass().add("date-hyperlink");
moreLabel.setOnMouseClicked(evt -> fireEvent(new RequestEvent(this, this, date)));
}
getChildren().add(moreLabel);
}
示例4: DayPageSkin
import javafx.beans.Observable; //導入依賴的package包/類
public DayPageSkin(DayPage view) {
super(view);
yearMonthView.getSelectedDates().addListener((Observable evt) -> {
if (yearMonthView.getSelectedDates().size() == 1) {
LocalDate date = yearMonthView.getSelectedDates().iterator().next();
getSkinnable().setDate(date);
}
});
updateView();
view.dateProperty().addListener(evt -> updateView());
view.dayPageLayoutProperty().addListener(it -> updateLayout());
updateLayout();
}
示例5: GoogleEntryDetailsView
import javafx.beans.Observable; //導入依賴的package包/類
public GoogleEntryDetailsView(GoogleEntry entry) {
super(requireNonNull(entry));
this.entry = entry;
Label notificationLabel = new Label("Notification:");
Label addButton = new Label("Add a notification");
addButton.getStyleClass().add("link");
addButton.setOnMouseClicked(evt -> createReminder());
addButton.disableProperty().bind(entry.getCalendar().readOnlyProperty());
VBox center = new VBox();
BorderPane notificationPane = new BorderPane();
notificationPane.setCenter(center);
notificationPane.setBottom(addButton);
GridPane box = (GridPane) getChildren().get(0);
box.add(notificationLabel, 0, 5);
box.add(notificationPane, 1, 5);
GridPane.setValignment(notificationLabel, VPos.TOP);
getStyleClass().add("details-view");
if (entry.isUseDefaultReminder()) {
GoogleCalendar calendar = (GoogleCalendar) entry.getCalendar();
reminders.addAll(calendar.getDefaultReminders());
}
reminders.addAll(entry.getReminders());
reminders.addListener((Observable obs) -> buildItems(center));
buildItems(center);
}
示例6: addColumnToView
import javafx.beans.Observable; //導入依賴的package包/類
private void addColumnToView(final SpecIoVariable specIoVariable) {
TableColumn<HybridRow, String> column = createViewColumn(specIoVariable.getName(),
hybridRow -> hybridRow.getCells().get(specIoVariable.getName()));
column.setUserData(specIoVariable.getName());
specIoVariable.nameProperty()
.addListener((Observable o) -> column.setUserData(specIoVariable.getName()));
column.setText("");
column.setGraphic(new ColumnHeader(specIoVariable));
column.setPrefWidth(specIoVariable.getColumnConfig().getWidth());
column.widthProperty().addListener(
(obs, old, newVal) -> specIoVariable.getColumnConfig().setWidth(newVal.doubleValue()));
column.setContextMenu(createColumnContextMenu(column));
tableView.getColumns().add(tableView.getColumns().size() - 1, column);
}
示例7: onPageChanged
import javafx.beans.Observable; //導入依賴的package包/類
protected void onPageChanged(Observable observable) {
int page = pageNumber.get();
wizardView.getTitleLabel().setText(wizardPages.get(page).getTitle());
wizardView.getPageNumberLabel().setText((page + 1) + "/" + wizardPages.size());
wizardView.setContent(wizardPages.get(page));
if (page == 0) {
wizardView.getPrevious().setDisable(true);
} else {
wizardView.getPrevious().setDisable(false);
}
if (page == wizardPages.size() - 1) {
wizardView.getNext().setOnAction(this::finish);
wizardView.getNext().setText("Finish");
} else {
wizardView.getNext().setOnAction(this::next);
wizardView.getNext().setText("Next");
}
}
示例8: SpecificationRow
import javafx.beans.Observable; //導入依賴的package包/類
/**
* Create a SpecificationRow from a given number of cells and an extractor. The extractor is
* required for "deep observing", i.e. the registering of change listeners on the contents of an
* observable collection (here, the collection of cells - to fire change events not only when
* cells are added or removed, but also when properties in the cells change). For more information
* on extractors, see https://docs.oracle
* .com/javase/8/javafx/api/javafx/collections/FXCollections.html.
*
* @param cells The initial cells of the row
* @param extractor The extractor to be used for deep observing on the cells
*/
public SpecificationRow(Map<String, C> cells, Callback<C, Observable[]> extractor) {
this.cells = FXCollections.observableMap(cells);
this.cells.addListener(this::cellsMapChanged);
this.listeners = new ArrayList<>();
this.comment = new SimpleStringProperty("");
this.extractor = extractor;
this.cells.addListener(this::listenRowInvalidation);
comment.addListener(this::listenRowInvalidation);
cells.values().forEach(this::subscribeToCell);
}
示例9: createExtractedVarsTextArea
import javafx.beans.Observable; //導入依賴的package包/類
private Node createExtractedVarsTextArea(VariableCollectionController controller, FreeVariableListValidator validator) {
final TextArea textArea = new TextArea();
textArea.getStyleClass().addAll("model-text-area");
textArea.setEditable(false);
FreeVariableList set = controller.getFreeVariableList();
updateText(textArea, set.getVariables());
set.getVariables().addListener((ListChangeListener<? super FreeVariable>) c ->
updateText(textArea, set.getVariables()));
final TextArea problemsArea = new TextArea();
problemsArea.getStyleClass().addAll("model-text-area");
textArea.setEditable(false);
updateProblemsText(problemsArea, validator);
validator.problemsProperty().addListener((Observable o) -> updateProblemsText(problemsArea, validator));
SplitPane splitPane = new SplitPane(textArea, problemsArea);
splitPane.setOrientation(Orientation.VERTICAL);
return splitPane;
}
示例10: onChange
import javafx.beans.Observable; //導入依賴的package包/類
/** fires handler if any of the observables change */
public static void onChange(Runnable handler, boolean immediately, Observable ... props)
{
// Helper li = new Helper(handler);
for(Observable p: props)
{
// p.addListener(li);
// weak listener gets collected... but why??
p.addListener((src) -> handler.run());
}
if(immediately)
{
handler.run();
}
}
示例11: deserialize
import javafx.beans.Observable; //導入依賴的package包/類
@Override
public ObservableList<Car> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonNode node = p.getCodec().readTree(p);
ObservableList<Car> cars = FXCollections.observableList(new ArrayList<Car>(), param -> new Observable[]{param.carClassProperty().get().classNameProperty(), param.carClassProperty().get().classColorProperty()});
Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();
while (iterator.hasNext()) {
Map.Entry<String, JsonNode> entry = iterator.next();
ArrayList<Integer> colorValues = new ArrayList<>();
for (final JsonNode colorValue : entry.getValue().findValue("color")) {
colorValues.add(colorValue.asInt());
}
CarClass carClass = new CarClass(entry.getKey(), Color.rgb(colorValues.get(0), colorValues.get(1), colorValues.get(2)));
for (final JsonNode car : entry.getValue().findValue("cars")) {
cars.add(new Car(car.asText(), carClass));
}
}
return cars;
}
示例12: handleCaptionChange
import javafx.beans.Observable; //導入依賴的package包/類
private void handleCaptionChange(Observable observable) {
TitleSlide slide = getSlide();
String caption = captionField.getText();
if (slide == null || slide.getCaption().equals(caption)) {
return;
}
slide.setCaption(caption);
try {
slideService.update(slide);
onUpdate();
} catch (ServiceException ex) {
ErrorDialog.show(root, "Fehler beim Ändern des Textes", "");
}
}
示例13: handleColorChange
import javafx.beans.Observable; //導入依賴的package包/類
private void handleColorChange(Observable observable) {
TitleSlide slide = getSlide();
int color = ColorUtils.toInt(colorPicker.getValue());
if (slide == null || color == slide.getColor()) {
return;
}
slide.setColor(color);
try {
slideService.update(slide);
onUpdate();
} catch (ServiceException ex) {
ErrorDialog.show(root, "Fehler beim Ändern der Farbe", "");
}
}
示例14: handleCaptionChange
import javafx.beans.Observable; //導入依賴的package包/類
private void handleCaptionChange(Observable observable) {
PhotoSlide slide = getSlide();
String caption = captionField.getText();
if (slide == null || slide.getCaption().equals(caption)) {
return;
}
slide.setCaption(caption);
try {
slideService.update(slide);
onUpdate();
} catch (ServiceException ex) {
ErrorDialog.show(root, "Fehler beim Ändern des Textes", "");
}
}
示例15: handleCaptionChange
import javafx.beans.Observable; //導入依賴的package包/類
private void handleCaptionChange(Observable observable) {
MapSlide slide = getSlide();
String caption = captionField.getText();
if (slide == null || slide.getCaption().equals(caption)) {
return;
}
slide.setCaption(caption);
try {
slideService.update(slide);
onUpdate();
} catch (ServiceException ex) {
ErrorDialog.show(root, "Fehler beim Ändern des Textes", "");
}
}