本文整理汇总了Java中javafx.beans.property.ReadOnlyObjectProperty.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ReadOnlyObjectProperty.addListener方法的具体用法?Java ReadOnlyObjectProperty.addListener怎么用?Java ReadOnlyObjectProperty.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.beans.property.ReadOnlyObjectProperty
的用法示例。
在下文中一共展示了ReadOnlyObjectProperty.addListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFindReplaceDialog
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
@Override
public FindReplaceDialog getFindReplaceDialog() {
if (findReplaceDialog == null) {
findReplaceDialog = new FindReplaceDialog(getWindow(), this);
ChangeListener<Node> focusOwnerListener = (observable, oldValue,
newValue) -> findReplaceDialog.getController().setFocusOwner(newValue);
ChangeListener<Scene> sceneListener = (observable, oldValue, newValue) -> {
if (oldValue != null)
oldValue.focusOwnerProperty().removeListener(focusOwnerListener);
if (newValue != null)
newValue.focusOwnerProperty().addListener(focusOwnerListener);
};
ReadOnlyObjectProperty<Scene> sceneProperty = root.sceneProperty();
sceneProperty.addListener(sceneListener);
sceneListener.changed(sceneProperty, null, sceneProperty.get());
}
return findReplaceDialog;
}
示例2: monitorStageScene
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
private void monitorStageScene(ReadOnlyObjectProperty<Scene> stageSceneProperty) {
// first listen to changes
stageSceneProperty.addListener(new ChangeListener<Scene>() {
@Override
public void changed(ObservableValue<? extends Scene> ov, Scene o, Scene n) {
if (o != null) {
unregisterScene(o);
}
if (n != null) {
registerScene(n);
}
}
});
if (stageSceneProperty.getValue() != null) {
registerScene(stageSceneProperty.getValue());
}
}
示例3: bindContextMenuForTreeTableCell
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
/**
* Helper method which provides extra logic for extracting the {@link TreeItem} {@link Property} from a
* {@link TreeTableCell}, which itself has no {@link TreeItem} property. The {@link TreeItem} {@link Property} we
* want to bind can be found in the containing {@link TreeTableRow} instead.
* <p>
*
* @param <T> the type of the item contained in the {@link TreeTableRow}
* @param appCtx the {@link ApplicationContext} of the application
* @param ctxMenuProperty the {@link ContextMenu} {@link Property} of the {@link TreeTableCell}
* @param tableRowProperty the {@link TreeTableRow} {@link Property} of the {@link TreeTableCell}
*/
private static <T> void bindContextMenuForTreeTableCell(ApplicationContext appCtx,
ObjectProperty<ContextMenu> ctxMenuProperty,
ReadOnlyObjectProperty<TreeTableRow<T>> tableRowProperty)
{
tableRowProperty.addListener((property, oldValue, newValue) ->
{
// If the containing TreeTableRow disappears, unbind the context menu if any
if (newValue == null)
{
ctxMenuProperty.unbind();
return;
}
// Otherwise, bind the ContextMenu to the TreeItem Property of the containing TreeTable row.
bindContextMenu(appCtx, ctxMenuProperty, newValue.treeItemProperty());
});
}
示例4: initializeTabChangeListener
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
public void initializeTabChangeListener(TabPane tabPane) {
ReadOnlyObjectProperty<Tab> itemProperty = tabPane.getSelectionModel().selectedItemProperty();
tabPane.setOnMouseReleased(event -> {
Optional.ofNullable(itemProperty)
.map(ObservableObjectValue::get)
.filter(e -> e instanceof MyTab)
.map(e -> (MyTab) e)
.map(MyTab::getEditorPane)
.ifPresent(EditorPane::focus);
});
itemProperty.addListener((observable, oldValue, selectedTab) -> {
Optional.ofNullable(selectedTab)
.filter(e -> e instanceof MyTab)
.map(e -> (MyTab) e)
.map(MyTab::getEditorPane)
.filter(EditorPane::getReady)
.ifPresent(EditorPane::updatePreviewUrl);
});
}
示例5: ConstraintSpecificationValidator
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
/**
* <p>
* Creates a validator with given observable models as context information.
* </p>
*
* <p>
* The validator observes changes in any of the given context models. It automatically updates the
* validated specification (see {@link #validSpecificationProperty()}) and/or the problems with
* the constraint specification (see {@link #problemsProperty()}).
* </p>
*
* @param typeContext the extracted types (esp. enums) from the code area
* @param codeIoVariables the extracted {@link CodeIoVariable}s from the code area
* @param validFreeVariables the most latest validated free variables from the
* {@link FreeVariableList}.
* @param specification the specification to be validated
*/
public ConstraintSpecificationValidator(ObjectProperty<List<Type>> typeContext,
ObjectProperty<List<CodeIoVariable>> codeIoVariables,
ReadOnlyObjectProperty<List<ValidFreeVariable>> validFreeVariables,
ConstraintSpecification specification) {
this.typeContext = typeContext;
this.codeIoVariables = codeIoVariables;
this.validFreeVariables = validFreeVariables;
this.specification = specification;
this.problems = new SimpleObjectProperty<>(new ArrayList<>());
this.validSpecification = new NullableProperty<>();
this.valid = new SimpleBooleanProperty(false);
// All these ObservableLists invoke the InvalidationListeners on deep updates
// So if only a cell in the Specification changes, the change listener on the ObservableList
// two layers above gets notified.
specification.getRows().addListener(listenToSpecUpdate);
specification.getDurations().addListener(listenToSpecUpdate);
specification.getColumnHeaders().addListener(listenToSpecUpdate);
typeContext.addListener(listenToSpecUpdate);
codeIoVariables.addListener(listenToSpecUpdate);
validFreeVariables.addListener(listenToSpecUpdate);
recalculateSpecProblems();
}
示例6: add
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
@SuppressWarnings("UnusedReturnValue")
public final CompositeObservableBounds add(ReadOnlyObjectProperty<Bounds> nodeBounds) {
LOGGER.trace("add({})", nodeBounds);
requireNonNull(nodeBounds, "nodeBounds is null");
if (!sourceBounds.contains(nodeBounds)) {
sourceBounds.add(nodeBounds);
observedBoundsChanged(nodeBounds, null, nodeBounds.get());
nodeBounds.addListener(this::observedBoundsChanged);
}
return this;
}
示例7: monitorBounds
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
void monitorBounds(final BoundsType boundsType) {
// remove the shape's previous boundsType.
if (boundsChangeListener != null) {
final ReadOnlyObjectProperty<Bounds> oldBounds;
switch (selectedBoundsType.get()) {
case LAYOUT_BOUNDS: oldBounds = monitoredShape.layoutBoundsProperty(); break;
case BOUNDS_IN_LOCAL: oldBounds = monitoredShape.boundsInLocalProperty(); break;
case BOUNDS_IN_PARENT: oldBounds = monitoredShape.boundsInParentProperty(); break;
default: oldBounds = null;
}
if (oldBounds != null) {
oldBounds.removeListener(boundsChangeListener);
}
}
// determine the shape's bounds for the given boundsType.
final ReadOnlyObjectProperty<Bounds> bounds;
switch (boundsType) {
case LAYOUT_BOUNDS: bounds = monitoredShape.layoutBoundsProperty(); break;
case BOUNDS_IN_LOCAL: bounds = monitoredShape.boundsInLocalProperty(); break;
case BOUNDS_IN_PARENT: bounds = monitoredShape.boundsInParentProperty(); break;
default: bounds = null;
}
// set the visual bounds display based upon the new bounds and keep it in sync.
updateBoundsDisplay(bounds.get());
// keep the visual bounds display based upon the new bounds and keep it in sync.
boundsChangeListener = new ChangeListener<Bounds>() {
@Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldBounds, Bounds newBounds) {
updateBoundsDisplay(newBounds);
}
};
bounds.addListener(boundsChangeListener);
}
示例8: initialize
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
public void initialize() {
ReadOnlyObjectProperty<LatestClearThreeDModelVotes> latestClearVotes = service.retrieveLatestClearVotes();
if (latestClearVotes.getValue() == null) {
latestClearVotes.addListener((obs, ov, nv) -> {
if (ov == null && nv != null) {
refreshView();
loadView();
if (!service.canVoteForOTN3DModel()) {
addResults();
}
}
});
} else {
latestClearVotes.getValue().timestampProperty().addListener((obs2, ov2, nv2) -> {
refreshView();
loadView();
if (!service.canVoteForOTN3DModel()) {
addResults();
}
});
}
imageGallery = new ImageGallery<>();
imageGallery.setImageFactory(otn3DModel -> {
ImageView imageView = new ImageView(ImageCache.get(otn3DModel.getImage()));
imageView.setPreserveRatio(true);
return imageView;
});
imageGallery.setTitleFactory(OTN3DModel::getName);
vote3DView.setOnShowing(event -> {
AppBar appBar = getApp().getAppBar();
appBar.setNavIcon(getApp().getNavBackButton());
appBar.setTitleText(OTNView.VOTE3D.getTitle());
loadView();
if (!service.canVoteForOTN3DModel()) {
addResults();
}
});
vote3DView.setOnHidden(event -> {
if(service.isAuthenticated()) {
imageGallery.clearSelection();
}
});
otn3DModels = service.retrieveOTN3DModels();
otn3DModels.addListener((ListChangeListener.Change<? extends OTN3DModel> c) -> {
refreshView();
loadView();
if (!service.canVoteForOTN3DModel()) {
addResults();
}
});
refreshView();
loadView();
if (!service.canVoteForOTN3DModel()) {
addResults();
}
imageGallery.setItems(nonPrinting3DModels);
// printingImage.fitWidthProperty().bind(vote3DView.widthProperty().subtract(10));
voteButton.setText(OTNBundle.getString("OTN.BUTTON.VOTE_TO_PRINT"));
voteButton.setOnAction(event -> {
if(imageGallery.getSelectedItem() != null) {
vote(imageGallery.getSelectedItem());
} else {
Toast toast = new Toast(OTNBundle.getString("OTN.EXPERIENCE.SELECT_IMAGE"));
toast.show();
}
});
}
示例9: initialize
import javafx.beans.property.ReadOnlyObjectProperty; //导入方法依赖的package包/类
@FXML
void initialize() {
messageList.setCellFactory(listView -> new ListCell<>() {
@Override
public void updateItem(Message item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
} else {
setText(item.displayText());
}
}
});
messageList.getSelectionModel().selectedItemProperty().addListener((ov, o, n) -> currentMessage.setValue(n));
TreeItem<Item> root = new TreeItem<>(new TreeNode(""));
root.setExpanded(true);
messageTree.setRoot(root);
messageTree.setShowRoot(false);
messageTree.setCellFactory(new TreeCellFactory());
messageTree.setOnMouseClicked(new TreeViewMouseHandler());
ReadOnlyObjectProperty<TreeItem<Item>> selectTreeNode = messageTree.getSelectionModel().selectedItemProperty();
selectTreeNode.addListener((ov, o, n) -> {
if (n == null || n.getValue() instanceof TreeNode) {
currentMessage.setValue(null);
} else {
Message message = (Message) n.getValue();
currentMessage.setValue(message);
}
});
ReadOnlyObjectProperty<Toggle> toggleProperty = viewTypeGroup.selectedToggleProperty();
StringBinding typeProperty = createStringBinding(() -> (String) toggleProperty.get().getUserData(), toggleProperty);
currentTreeItem.bind(Bindings.createObjectBinding(() -> {
if (!"tree".equals(typeProperty.get())) {
return null;
}
return selectTreeNode.get();
}, typeProperty, selectTreeNode));
typeProperty.addListener((ov, o, type) -> {
if (type.equals("list")) {
stackPane.getChildren().remove(messageList);
stackPane.getChildren().add(messageList);
} else if (type.equals("tree")) {
stackPane.getChildren().remove(messageTree);
stackPane.getChildren().add(messageTree);
}
});
}