This document discusses JavaFX 2 and how it can make Java sexy again. It provides an overview of JavaFX concepts like controls, properties, layouts, events, CSS styling and FXML. It demonstrates how to create simple JavaFX applications with basic UI elements and handlers. It also discusses advanced topics such as binding properties, creating custom controls with CSS and using JavaFX UI tools. The goal is to introduce developers to the new features in JavaFX 2 that aim to simplify UI development and create rich and responsive client applications.
6. • Java language features
• FXML for defining user interfaces
• New graphics pipeline for modern GPUs
• Rich set of UI controls
• Powerful Properties Model
• Swing and AWT Interoperability
7. JavaFX Public APIs and Scene Graph
Quantum Toolkit
Prism
Java 2D
Open GL
3D
Glass
Windowing
Toolkit
Media
Engine
Web
Engine
30. javafx.application.Application
public class HelloJavaFX extends Application {
Top level container
@Override
public void start(Stage stage) {
Root container
BorderPane root = new BorderPane();
Button btn = new Button("Hello JavaFX!");
root.setCenter(btn);
Place Button
Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Run...
41. Label mile = new Label();
KM to mile
double kmValue = 32.5;
double mileValue = kmValue * 0.621371192;
String mileText = Double.toString(kmValue);
mile.setText(mileText);
Set Label text
Double to String
42. KM Property Object
DoubleProperty kmPro = new SimpleDoubleProperty();
Label mile = new Label();
StringBinding Object, hold
KM to mile value
StringBinding mileBinding =
kmPro.multiply(0.621371192).asString();
mile.textProperty().bind(mileBinding);
Bind mile value to
...
Text Property
kmPro.set(32.5);
Change KM Property value
43. DoubleProperty kmPro = new SimpleDoubleProperty();
Label mile = new Label();
Extends Binding Class
StringBinding mileBinding = new StringBinding() {
{
Binding Property
super.bind(kmPro);
}
Override computeValue method
@Override
protected String computeValue() {
return Double.toString(kmPro.get() * 0.621371192);
}
Produce value here
};
mile.textProperty().bind(mileBinding);
...
kmPro.set(32.5);