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


Java Observable類代碼示例

本文整理匯總了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());
        }
    });
}
 
開發者ID:comtel2000,項目名稱:mokka7,代碼行數:21,代碼來源:SessionManager.java

示例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;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:NodePropertiesSample.java

示例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);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:30,代碼來源:MonthViewSkin.java

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

示例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);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:35,代碼來源:GoogleEntryDetailsView.java

示例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);
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:17,代碼來源:SpecificationTableController.java

示例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");
  }
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:19,代碼來源:WizardManager.java

示例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);
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:23,代碼來源:SpecificationRow.java

示例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;
}
 
開發者ID:VerifAPS,項目名稱:stvs,代碼行數:25,代碼來源:VariableCollectionDemo.java

示例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();
		}
	}
 
開發者ID:andy-goryachev,項目名稱:FxEditor,代碼行數:19,代碼來源:Binder.java

示例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;
}
 
開發者ID:SenorPez,項目名稱:project-cars-replay-enhancer-ui,代碼行數:22,代碼來源:Configuration.java

示例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", "");
    }
}
 
開發者ID:travelimg,項目名稱:travelimg,代碼行數:18,代碼來源:TitleSlideInspectorImpl.java

示例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", "");
    }
}
 
開發者ID:travelimg,項目名稱:travelimg,代碼行數:18,代碼來源:TitleSlideInspectorImpl.java

示例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", "");
    }
}
 
開發者ID:travelimg,項目名稱:travelimg,代碼行數:18,代碼來源:PhotoSlideInspectorImpl.java

示例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", "");
    }
}
 
開發者ID:travelimg,項目名稱:travelimg,代碼行數:18,代碼來源:MapSlideInspectorImpl.java


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