JavaFX_ObjectToObject1
 
 
Code :

package javafxtemplate1;
// without a divider
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javafx.scene.layout.TilePane;
import javafx.scene.layout.VBox;

/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//

@Override

public void start(Stage primaryStage)
{
//
// Group groot = new Group();
VBox groot = new VBox();
EMP2 emp2 = new EMP2();
Emp1 emp1 = new Emp1("John", "Smith", 2500.25);
Emp1 emp3 = new Emp1("Harry", "Smith", 3500.25);
emp2.setfirstName("John");
emp2.setlastName("Smith");
emp2.setSalary(2500.55);
//
ObjectProperty<Emp1> oemp1 = new SimpleObjectProperty<>(emp1);
ObjectProperty<Object> oemp2 = new SimpleObjectProperty<>(emp3);
StringProperty prop1 = new SimpleStringProperty("");
prop1.bindBidirectional(emp1.firstNameProperty());
StringProperty prop2 = new SimpleStringProperty("");
prop2.bindBidirectional(emp1.lastNameProperty());
DoubleProperty prop3 = new SimpleDoubleProperty();
prop3.bindBidirectional(emp1.salaryproperty());
//
//ObjectProperty<Emp1> oemp1 = new SimpleObjectProperty<>(emp1);
//
Label label1 = new Label(emp2.getfirstName());
Label label2 = new Label(emp2.getlastName());
Label label3 = new Label(emp2.getSalary().toString());
//
Label label4 = new Label(prop1.get());
Label label5 = new Label(prop2.get());
Label label6 = new Label(prop3.asString().get());
Label label7 = new Label(oemp1.asString().get());
Label label8 = new Label("----as an object-------");
Label label9 = new Label(oemp2.asString().get());
//
TilePane tPane1 = new TilePane(); // scenelayout package FlowPane
TilePane tPane2 = new TilePane();
TilePane tPane3 = new TilePane();
tPane1.setVgap(20); tPane1.setHgap(20);
tPane2.setVgap(20); tPane2.setHgap(20);
tPane3.setVgap(20); tPane3.setHgap(20);
//
tPane3.getChildren().addAll(label8,label7, label9);
tPane2.getChildren().addAll(label4, label5, label6);
tPane1.getChildren().addAll(label1, label2, label3);
//

//
groot.getChildren().addAll(tPane1, tPane2, tPane3);
Scene scene = new Scene(groot, 300, 250, Color.WHITE);
primaryStage.setTitle("Properties :: Binding");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);

}

}