Skip to content

Instantly share code, notes, and snippets.

Avatar

Johannes Rupprecht RupprechJo

View GitHub Profile
View custom binding example
//Simple custom IntegerBinding implementation
IntegerProperty intVal = new SimpleIntegerProperty();
IntegerBinding modulo2 = new IntegerBinding() {
{ bind(intVal);}
protected int computeValue() {
return intVal.get() % 2;
}
};
intVal.set(3);
Assert.assertEquals(1, modulo2.get());
View Standard binding examples
//Binding with the bind method of a property
StringProperty prop1 = new SimpleStringProperty();
StringProperty prop2 = new SimpleStringProperty();
prop1.bind(prop2);
prop2.set("Hello World");
Assert.assertEquals(prop1.get(), prop2.get());
//Binding with Bindings.add method
@RupprechJo
RupprechJo / gist:7527454
Last active Dec 28, 2015
NestedObjectProperty class
View gist:7527454
import javafx.beans.property.Property;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
import javafx.beans.value.WeakChangeListener;
import java.util.function.Function;
/**
* A Property which is unidirectionally or bidirectionally bound to a property of a property. What that means:
* You have a property A. The object contained in that property A has itself a property B.
View JavaFx Zooming Example
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane;
View JavaFx Scaling Example
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class ScalingDemo extends Application{
public void start(Stage primaryStage) throws Exception {
WebView webView = new WebView();