scrollPane.getContent().getParent().addEventHandler(ScrollEvent.ANY, scrollHandler); scrollPane.getContent().parentProperty().addListener((o,oldVal, newVal)->{ if (oldVal != null) { oldVal.removeEventHandler(MouseEvent.DRAG_DETECTED, dragHandler);
private void displayLabelForData(XYChart.Data<String, Number> data) { final Node node = data.getNode(); final Text dataText = new Text(data.getYValue() + ""); node.parentProperty().addListener(new ChangeListener<Parent>() { @Override public void changed(ObservableValue<? extends Parent> ov, Parent oldParent, Parent parent) { Group parentGroup = (Group) parent; parentGroup.getChildren().add(dataText); } }); node.boundsInParentProperty().addListener(new ChangeListener<Bounds>() { @Override public void changed(ObservableValue<? extends Bounds> ov, Bounds oldBounds, Bounds bounds) { dataText.setLayoutX( Math.round( bounds.getMinX() + bounds.getWidth() / 2 - dataText.prefWidth(-1) / 2 ) ); dataText.setLayoutY( Math.round( bounds.getMinY() - dataText.prefHeight(-1) * 0.5 ) ); } }); }
@Override public void changed(final ObservableValue<? extends Node> observable, final Node oldValue, final Node newValue) { if (newValue != null) { AbstractBaseModel.this.hasBeenAttached = true; } if (newValue == null && AbstractBaseModel.this.hasBeenAttached) { AbstractBaseModel.this.hasBeenAttached = false; release(); node().parentProperty().removeListener(this); } }
/** * Attach a custom listener that will release the mode when the rootNode is removed from its parent. */ protected void attachParentListener() { final AutoRelease ar = ClassUtility.getLastClassAnnotation(this.getClass(), AutoRelease.class); // Only manage automatic release when the annotation exists with true value if (ar != null && ar.value() && node() != null) { // TODO check rootnode null when using NullView // Allow to release the model if the root business object doesn't exist anymore node().parentProperty().addListener(new ChangeListener<Node>() { @Override public void changed(final ObservableValue<? extends Node> observable, final Node oldValue, final Node newValue) { if (newValue != null) { AbstractBaseModel.this.hasBeenAttached = true; } if (newValue == null && AbstractBaseModel.this.hasBeenAttached) { AbstractBaseModel.this.hasBeenAttached = false; release(); node().parentProperty().removeListener(this); } } }); } }
scrollPane.getContent().getParent().addEventHandler(ScrollEvent.ANY, scrollHandler); scrollPane.getContent().parentProperty().addListener((o,oldVal, newVal)->{ if (oldVal != null) { oldVal.removeEventHandler(MouseEvent.DRAG_DETECTED, dragHandler);