javafx and html5 - like curds and rice

26
JavaFX and HTML5 – Like Curds and Rice Stephen Chin Java Evangelist, Oracle [email protected] tweet: @steveonjava Kevin Nilson VP of Engineering, Just.Me [email protected] tweet: @javaclimber

Upload: stephen-chin

Post on 27-Jan-2015

108 views

Category:

Technology


0 download

DESCRIPTION

JavaFX 2 is an exciting new platform for developing rich user interfaces with animation, media, and advanced controls with pure Java code. HTML5 is the next standard for web technologies promising richer graphics, native media support, and offline storage among other features. So which technology should you choose? We say you can have your curds with your rice! With one HTML5 expert and one JavaFX wizard on stage, we will show how you can leverage both of these technologies to create a new breed of application that goes beyond your expectations.

TRANSCRIPT

Page 1: JavaFX and HTML5 - Like Curds and Rice

JavaFX and HTML5 – Like Curds and Rice

Stephen ChinJava Evangelist, [email protected]: @steveonjava

Kevin NilsonVP of Engineering, [email protected]: @javaclimber

Page 2: JavaFX and HTML5 - Like Curds and Rice

About the Presenters

Stephen Chin

Java Evangelist, Oracle

Author, Pro JavaFX Platform 2

Kevin Nilson

User GroupsSilicon Valley Web JUGSilicon Valley JS MeetupSilicon Valley Google Technology UG

VP of Engineering, Just.Me Author Web 2.0 Fundamentals

Java Champion

SV JavaFX User Group Founder

Page 3: JavaFX and HTML5 - Like Curds and Rice

Photo by Kaushal Karkhanis: http://www.flickr.com/photos/kaushal/

Page 4: JavaFX and HTML5 - Like Curds and Rice

History of the Web

• 1991 HTML• 1994 HTML 2• 1996 CSS 1 + JavaScript• 1997 HTML 4• 1998 CSS 2• 2000 XHTML 1• 2002 Tableless Web Design• 2005 AJAX• 2009 HTML 5

Page 5: JavaFX and HTML5 - Like Curds and Rice

What is HTML5

• Web Hypertext Application Technology Working Group (WHATWG)

• HTML5 ! = HTML + CSS + JavaScript• HTML5 = Next Generation Features for Modern Web

Development

• Offline Storage, Web SQL Database, IndexedDB, Application Cache, Web Workers, WebSocket, Notifications, Native Drag & Drop, File System, GeoLocation, Speech Input, Form Types, Audio, Video, Canvas, SVG

Page 6: JavaFX and HTML5 - Like Curds and Rice

HTML5 Rounded Corners

• http://slides.html5rocks.com/#rounded-corners

HTML5No HTML5

Page 7: JavaFX and HTML5 - Like Curds and Rice

HTML5 Canvas 3D (WebGL)

• http://oos.moxiecode.com/js_webgl/fish/index.html

Page 8: JavaFX and HTML5 - Like Curds and Rice

Prefixes

• -webkit-text-fill-color: black;• -webkit-column-count: 2;

• Before the Spec is final

• Before the Browser implementation is Verified

Page 9: JavaFX and HTML5 - Like Curds and Rice

Cross Browser

• Browsers behave fairly differently

• HTML5 Non-Ambiguous Spec

• JavaScript Frameworks (jQuery, Dojo, YUI) give consistent API

Page 10: JavaFX and HTML5 - Like Curds and Rice

Acid Test

• http://acid3.acidtests.org

Page 11: JavaFX and HTML5 - Like Curds and Rice

jQuery On The Rise> 56.87% of Top 10,000 sites use jQuery

(builtwith.com)

Page 12: JavaFX and HTML5 - Like Curds and Rice

jQuery

12

• http://jsfiddle.net/3urR9

Page 13: JavaFX and HTML5 - Like Curds and Rice

Reaching Older Browsers

• Chrome Frame• IE6, IE7, IE8 running Chrome

• Modernizer• Feature detection rather than User Agent

Sniffing

Page 14: JavaFX and HTML5 - Like Curds and Rice

Bootstrap

14

Page 15: JavaFX and HTML5 - Like Curds and Rice

Responsive UI

15

http://earthhour.fr

Page 16: JavaFX and HTML5 - Like Curds and Rice

JavaFX 2.0 Platform

Immersive Desktop Experience Combining the Best of JavaFX and HTML5

• Leverage your Java skills with modern JavaFX APIs

• Integrate Java, JavaScript, and HTML5 in the same application

• New graphics stack takes advantage of hardware acceleration for 2D and 3D applications

• User your favorite IDE: NetBeans, Eclipse, IntelliJ, etc.

Page 17: JavaFX and HTML5 - Like Curds and Rice

• iPhone UIWebView Formatting Text

Indalo is an iPhone App Kevin Helped Write

Page 18: JavaFX and HTML5 - Like Curds and Rice

• Titanium• Write JavaScript, but

Renders Native Application

• Many “Native” widgets are UIWebView

E*Trade API Contest App Kevin Wrote

Page 19: JavaFX and HTML5 - Like Curds and Rice

Displaying HTML in JavaFX

public class WebViewTest extends Application { public static void main(String[] args) { launch(WebViewTest.class, args); } @Override public void start(Stage stage) { WebView webView = new WebView(); webView.getEngine().load("http://google.com"); Scene scene = new Scene(webView); stage.setScene(scene); stage.setTitle("Web Test"); stage.show();}}

19

Page 20: JavaFX and HTML5 - Like Curds and Rice

Displaying HTML in JavaFX

20

Page 21: JavaFX and HTML5 - Like Curds and Rice

Calling Javascript from JavaFX

String script = "alert('We have got a message, Houston!');”;eng.executeScript(script);

21

Page 22: JavaFX and HTML5 - Like Curds and Rice

JavaScript to Java Type Conversion

JavaScript Javanull nullundefined “undefined”number java.lang.Number

(Integer or Double)string java.lang.Stringboolean java.lang.Booleanobject netscape.javascript.JSOb

ject

22

Page 23: JavaFX and HTML5 - Like Curds and Rice

Responding to Browser Events

Supported Events:

• Alert/Confirm/Prompt:

• Respond to JavaScript user interaction functions

• Resize:

• Web page moves or resizes the window object

• Status

• Web page changes the status text

• Visibility

• Hide or show the window object

• Popup

• Spawn a second web view/engine23

Page 24: JavaFX and HTML5 - Like Curds and Rice

HTML5/JavaFX Integration Demo

24

Page 25: JavaFX and HTML5 - Like Curds and Rice

Pro JavaFX 2 Platform

• All examples rewritten in Java• Covers new controls including:

WebPane TableView TreeView Etc.

• Content on ScalaFX/GroovyFX/Visage

25