javafx - lessons learned? · •css •extensions! except... chrome desktop. back vs. javadoc...

68
JavaFX - Lessons Learned? Ein Vergleich mit WPF(X) @phdoerfler imbus AG

Upload: others

Post on 23-Aug-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

JavaFX - Lessons Learned?Ein Vergleich mit WPF(X)

@phdoerflerimbus AG

Page 2: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

• Vorspeiße• Motivation• Hauptgang• Featurebuffet• Scenegraph• Properties• XML• Expression Binding• Nachtisch• Demo• Fazit

Speisekarte

Page 3: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

$: whoami• Philipp Dörfler•Medieninformatik an der „Technischen

Hochschule Nürnberg - Georg Simon Ohm“

• ~5 Jahre zu viel Enterprise• Scala• JavaFX• sbt-fxml• Twitter, etc.

Page 4: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Who Cares?

JVM.NET

Desktop

Page 5: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

And The Winner Is...

Page 6: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

WEB!•Cross-Platform•Kaum Deployment-Aufwand•Trivial•Wie Desktop-Apps•Ajax! Echtzeit!•CSS•Extensions!

Page 7: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows
Page 8: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Except...

Page 9: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Chrome Desktop

Page 10: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Back vs. Javadoc

Page 11: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

´nuff sa(I)d

Page 12: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

FX

Yay!WPF&

Page 13: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Ein kleiner ExkursAWT 1995

Swing 1997

SWT 20012002 Windows Forms

F3 2006 WPF 3.02007 WPF 3.5

JavaFX 1.0 2008 WPF 3.5sp1

2010 WPF 4.0JavaFX 2.0 2011JavaFX 2.2 2012 WPF 4.5

Page 14: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

• Java 8•Lecker Lambdas• Printing•3D•Modena•Native Font Rendering•High-DPI

JavaFX 8

Page 15: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

JavaFX 8•Default Classpath•Gradle Build•SwingNode•TreeTable•WebView Performance•Besseres Multithreading• ...

II

Page 16: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames

Page 17: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames•Legacy-Ablöser• WinForms• Swing

•Deklarativ•Reaktiv•Properties•Binding

Page 18: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames•Scene-Graph• Hoher Abstraktionsgrad• Einheitliche API

•Retained Mode•Animationen•Styling•GUI <|> Daten

II

Page 19: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames•XML für GUIs• XAML• FXML• Typkonvertierung

•Graphische GUI-Designer• Visual Studio• Blend• Scene Builder

III

Page 20: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames•Multithreading• Application Thread• Rendering Thread• Media Thread

•Multimedia•HW-Beschleunigung• Direct3D• OpenGL

IV

Page 21: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Gemeinsames•Accessability•Effekte•Multitouch•Event-Handling• Browser• XAML Browser Applications (XBAP)• Silverlight• Applets

V

Page 22: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Scene Graph

Page 23: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Scene graph•Logische Bäume• Deklarierter Scenegraph• Vererbungslogik von Properties

•Visueller Baum• Rendering• Event routing• Keine ContentElement• Nur Visual / DependencyObject

WPFTemplates

Page 24: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Logische BäumeWindow

StackPanel

Label

String

Page 25: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Logische BäumeWindow

StackPanel

Label

String

Window

StackPanel

Label

TextBlock

Border

AdornerDecorator

ContentPresenter

Border

ContentPresenter

UN-

Page 26: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Pfadfinder•Skin•SkinBase (FX 8)

•LogicalTreeHelper•VisualTreeHelper

FX

WPF

Page 27: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties

Page 28: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties• .NET CLR Properties

private int x;public int X { get { return x; } set { x = value; }}

• Java Propertiesprivate int x;public int getX() { return x; }public int setX(int value) { x = value; }

Beans!

Page 29: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

zzzzzz

Page 30: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties

Callbacks

Callback Hell

onActionPerformed

list.addAll(...) list.remove(model.

getById(42))

Page 31: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties

button.text <== when(ponyAvailable) "Satteln" otherwise "Rufen"

ScalaFX

Page 32: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Callbacks?

Page 33: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties• .NET / WPF• Properties• Dependency Properties• Attached Properties

• Java / FX• Beans• Properties

Done Right

Page 34: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Features!•Change Notification•Value Validation•Binding•Animationen•Value Inheritance•Styles WPF

Page 35: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPFDependency-

public static readonly DependencyProperty PoniesAwakeProperty = DependencyProperty.Register(„PoniesAwake“, typeof(int), typeof(MainWindow));

public int PoniesAwake{ get { return (int)GetValue(PoniesAwakeProperty); } set { SetValue(PoniesAwakeProperty, value); }}

PoniesAwake = 23;

Owner Type

Button myButton = new Button();myButton.Width = 200.0;

Property Type

<Button Width=“200“ />

Verwendung

Page 36: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPFDependency-

public static readonly DependencyProperty IsPonyProperty = DependencyProperty.Register(„IsPony“, typeof(bool), typeof(MainWindow), new FrameworkPropertyMetadata((bool) false, new PropertyChangedCallback(OnIsPonyChanged)));

public bool IsPony{ get { return (bool)GetValue(IsPonyProperty); } set { SetValue(IsPonyProperty, value); }}

private static void OnIsPonyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){ MainWindow target = (MainWindow) d; bool oldIsPony = (bool)e.OldValue; bool newIsPony = target.IsPony; target.OnIsPonyChanged(oldIsPony, newIsPony);}

II

Page 37: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPF•Metadaten•Default-Wert•Callbacks• Render-Infos• AffectsMeasure (sorgt für

Größenberechnung)• ...•Vererbungs-Infos

Dependency-

DependencyProperty.RegisterIII

Page 38: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPFAttached-

DependencyObject dep = new DependencyObject();dep.SetValue(Canvas.TopProperty, 42);

double top;top = (double) dep.GetValue(Canvas.TopProperty);

<DockPanel> <CheckBox DockPanel.Dock=“Top“>Hello</CheckBox></DockPanel>

DependencyProp

erty.RegisterA

ttached

XAML

Page 39: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPF•Globale Property-Tabelle•Konventionen• CLR-Properties• Außer bei AttachedProperty• GetFoo• SetFoo

•Eng mit GUI verzahnt

Page 40: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in WPF•Viel Syntax•Microsofts Lösung:• Snippet in Visual Studio!•Untypisiert•Sehr flexibel•Zu flexibel?• Ändern des Scenegraphs über Listener in AttachedPropertys

II

Page 41: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in FXprivate DoubleProperty amountDue = new SimpleDoubleProperty();public final double getAmountDue() { return amountDue.get(); }public final void setAmountDue(double value) { amountDue.set(value); }public DoubleProperty amountDueProperty() { return amountDue; }

amountDueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue o, Object oldVal, Object newVal) { System.out.println(“yay“); }});

setAmountDue(100.0);

Page 42: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in FX• AttachedProperty?•Statischer Setter & Getter!

<GridPane> <Label text="My Label" GridPane.columnIndex=“0“ /> ...</GridPane>

Label label = new Label("My Label");GridPane.setColumnIndex(label, 0);

class GridPane { public static void setColumnIndex(Node node, Integer value);}

II

Page 43: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in FX•Lazy Evaluation•Change-, InvalidationListener•Typisiert• Generics

•Metadata• Annotations

III

Page 44: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Properties in FX•Unabhängig von der GUI•Validierung•Ebenfalls flexibel•Viel pragmatischer•Rein berechnete Propertys möglich

IV

Page 45: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

XML

Page 46: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

FXML & XAML•Serialisierung des logischen Objektgraphen•Default properties• z.B. ListView.children

•Toolsupport•Skripting-Support

Page 47: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

FXML<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?><?import java.util.*?><?import javafx.scene.control.*?><?import javafx.scene.layout.*?><?import javafx.scene.paint.*?>

<StackPane id="rootPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml" fx:controller="org.foo.Conny">    <Button fx:id="heyButton" text="Hey!" StackPane.alignment="CENTER_RIGHT" /></StackPane>

Obligatorisches XML-Zeug

Imports als Prozessor-Anweisung

Variable im Controllerfx:idid CSS ID -> HTML ID

Controller-Klasse

Page 48: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

FXML•Attribute mit „fx:“

FXMLLoader•Attribute ohne „fx:“

normale Properties

•Attribute mit „.“statische Properties

II

attached

Page 49: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

XAML

<Window xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”       xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” x:Class="Org.Foo.Conny">    <StackPanel>        <Button Name="heyButton" Content="Hey!" />    </StackPanel></Window>

Namespaces

Variable im Code Behind

Code Behind Klasse

Page 50: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

XAML•Keine Prozessor-Anweisungen für Imports•Wird über Namespaces abgebildet•Mapping von CLR- nach XML-Namespaces nötig

II

Page 51: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Expression Binding<TextField fx:id="texty" text="some text" /><Label text="${'This is ' + texty.text}" textFill="BLUE">

<TextBox Name="Texty" Text="SPARTA"/><TextBlock Text="{Binding ElementName=Texty, Path=Text, StringFormat='This is {0}'}"/>

* nicht bei WinRT

FXML

XAML*

Page 52: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

„Simple Expressions“

„Only simple expressions that resolve to property values or page variables are currently supported. Support for more complex expressions involving boolean or other operators may be added in the future.“ ~ FXML Doc

Page 53: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

„Simple Expressions“ II

text="${'this is some ' + textField.text}"

selected="${(a.selected &amp;&amp; b.selected) || c.selected}"

selected=“${! true && false}“

= true

Page 54: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

„Simple Expressions“ III

DO NOT RELY ON IT yet

Page 55: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

FXML Beispiel<?language javascript?>

...

<fx:script><![CDATA[   function handleRectEnter(target) {       target.setText(event.getSource().getText());       target.getStyleClass().clear();       target.getStyleClass().add('desc-focused');   }   function handleRectLeave(target) {       target.getStyleClass().clear();       target.getStyleClass().add('desc');   }]]></fx:script>

...

<Button onMouseClicked="java.lang.System.out.println('You clicked me!');" onMouseEntered="handleRectEnter(quad1Text);" onMouseExited="handleRectLeave(quad1Text);" />

<Text fx:id="quad1Text" text="Action 1" />

JavaScript, Groovy, Clojure, JRuby, ...

Page 56: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Deklarationen

<fx:define>  <Button fx:id="b" prefHeight="32.0" prefWidth="32.0" text="Button" /></fx:define>

<Button maxHeight="${b.prefHeight}" />

FXML

Page 57: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Deklarationen

<Window.Resources>  <SolidColorBrush x:Key="backgroundBrush">Yellow</SolidColorBrush></Window.Resources><Window.Background>  <StaticResource ResourceKey="backgroundBrush" /></Window.Background>

...

<Button Background="{StaticResource backgroundBrush}" />

XAML

Page 58: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Presentation Model

Page 59: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Presentation Model

„This example is a proposal, it won’t work today. We are thinking about adding support for this in an upcoming update release.“ - Richard Bair, 14. Oktober 2011

Page 60: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Verbiegbarkeit

Page 61: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Verbiegbarkeit

<ListBox ItemSource=“{Binding Ponies}“> <ListBox.ItemTemplate> <DataTemplate> <TextBox Text=“{Binding Name}“/> </DataTemplate> </ListBox.ItemTemplate></ListBox>

Page 62: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Data Templates• In XAML als Resource deklarierbar•DataType-Property: automatisch auf passende Typen angewandt• HierarchicalDataTemplate

Page 63: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Fazit

Page 64: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

•Tooling umfrangreicher•Windows „only“•Dafür natives L&F•Over-engineered• Property-System komplex•Gutes Text-Rendering•Attached- & RoutedEvents

WPF

Page 65: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

JavaFX•Cross-Platform (!)•Simplere API•Offene Baustelle•Tooling schlanker•Leichter skinbar•Open-Source•RoutedEvents

Page 66: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Letzte Worte•Kein Gewinner•Beide gut•Windows, .NET => WPF•Mac, Linux, JVM => JavaFX

Page 67: JavaFX - Lessons Learned? · •CSS •Extensions! Except... Chrome Desktop. Back vs. Javadoc ´nuff sa(I)d. FX Yay! WPF & Ein kleiner Exkurs AWT 1995 Swing 1997 SWT 2001 2002 Windows

Vielen Dank!

@phdoerflerimbus AG