Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scripting with Java FX Your Name Sun Campus Ambassador Your Address.

Similar presentations


Presentation on theme: "Scripting with Java FX Your Name Sun Campus Ambassador Your Address."— Presentation transcript:

1 Scripting with Java FX Your Name Sun Campus Ambassador Your Email Address

2 Why Java FX? What is Java FX? Agenda The 10 Minute Tutorial What To Do/Where To Go Java FX Demo!

3 Introduction: What is Java FX? “JavaFX Script is a highly productive scripting language that enables content developers to create rich media and content for deployment on Java environments. JavaFX Script is a declarative, statically-typed programming language. It has first- class functions, declarative syntax, list-comprehensions, and incremental dependency-based evaluation. It can make direct calls to Java APIs that are on the platform.” --https://openjfx.dev.java.net/

4 Why Java FX? Writing GUIs is hard (and annoying) > Yes, Matisse helps quite a bunch, but... > There are still too many listeners.

5 Why Java FX? Writing GUIs is hard (and annoying) > Yes, Matisse helps quite a bunch, but... > There are still too many listeners. GUIs by default are ugly > A hierarchy of rectangular “grey boxes” (not limited to Java!) > Not as snazzy as Flash websites

6 Why Java FX? Yuk! -- Christopher Oliver, Sun Microsystems, Inc. Java One 2007

7 Why Java FX? Writing GUIs is hard (and annoying) > Yes, Matisse helps quite a bunch, but... > There are still too many listeners. GUIs by default are ugly > A hierarchy of rectangular “grey boxes” (not limited to Java!) > Not as snazzy as Flash websites Java 2D provides much what is needed, but... > It is rather difficult to use for this purpose > It does not have “compositional” behavior Java FX's declarative syntax, combining Swing-like user-interface widgets with compositional, Java 2D-like functionality makes writing flashy graphical user interfaces easy!

8 Java FX: The 10 Minute Tutorial class HelloWorldModel { attribute saying: String; } var model = HelloWorldModel { saying: "Hello Campus" }; var win = Frame { title: bind "{model.saying} JavaFX" width: 200 content: TextField { value: bind model.saying } visible: true }; Class definition with single String attribute Instance of the class called “model” which initializes string Frame with a single text field. Frame's title and text field's value is bound to model's attribute.

9 Java FX: The 10 Minute Tutorial import java.lang.StringIndexOutOfBoundsException; operation substring(s:String, n:Number): String { try { return s.substring(n); } catch (e:StringIndexOutOfBoundsException) { throw “sorry, index out of bounds”; } Defining operations (i.e. methods) Calling Java methods Can throw any object you like

10 Java FX: The 10 Minute Tutorial var x = [1,2,3]; insert 10 into x; insert 12 before x[1]; delete x[. == 12]; delete x[. >= 3]; insert 5 after x[. == 1]; insert 13 as first into x; delete x; Array Initialization yields [1, 2, 3, 10] yields [1, 12, 2, 3, 10] yields [1, 2, 3, 10] yields [1, 2] yields [1, 5, 2] yields [13, 1, 5, 2] yields [] function factors(n) { return select i from i in [1..n/2] where n % i == 0; } Database-like Queries for Arrays!

11 Java FX: The 10 Minute Tutorial class X { attribute nums: Number*; } trigger on new X { insert [3,4] into this.nums; } trigger on insert num into X.nums { System.out.println("just inserted {num} into X.nums at position {indexof num}"); } trigger on X.num[oldValue] = newValue { System.out.println("X.num: just replaced {oldValue} with {newValue}"); } Object creation trigger Array insertion trigger Array replacement trigger

12 Java FX: The 10 Minute Tutorial import javafx.ui.canvas.*; import javafx.ui.*; Canvas { content: Group { transform: [rotate(20,0,0)] content: [Rect { x: 20 y: 20 height: 80 width: 300... }, Ellipse { cx: 150 cy: 80... }, }] } Canvas object for arbitrary drawing Group objects together Transform groups Declarative 2D Graphics

13 demo

14 Download Java FX & IDE Plugins for Netbeans or Eclipse Join OpenJFX Java.net Project Do Java FX Tutorials Participate on Java FX Forums Create something cool! Java FX What to Do

15 Java FX Resources Java FX Project Site: http://openjfx.dev.java.nethttp://openjfx.dev.java.net > Java.net: Download early versions of Java FX > IDE Plugins, Tutorials, Forums, FAQs > “Getting Started With the JavaFX Script Language” > “JavaFX Script 2D Graphics Tutorial” > “The JavaFX Script Programming Language Reference” Planet FX Wiki: http://jfx.wikia.com/wiki/Main_Pagehttp://jfx.wikia.com/wiki/Main_Page > Open-source documentation site for Java FX Chris Oliver's Blog: http://blogs.sun.com/chrisoliver/http://blogs.sun.com/chrisoliver/ > Latest news, other informal information > Source code for lots of demos (Space Invaders, Calculator) Sun's Java FX Site: http://www.sun.com/software/javafx/http://www.sun.com/software/javafx/ > Sun Microsystems official product page

16 Fast Track Your Career with Sun! Get FREE Web-based training on Java TM, Solaris TM & more! > Visit: http://www.sunacademic.com > Course registration code for ABC University is XYZ Increase earnings potential with a Sun Certification! > Sun Certified Associate/Programmer for the Java 2 Platform SE > Sun Certified Web Component Developer for Java EE > Sun Certified Mobile Application Developer for Java ME > Sun Certified System/Network Admin for Solaris Operating System Free practice exams Discounted exams fees for academic developers – only US$60 (US$40 in APAC and Latin America)

17 THANK YOU! Scripting with Java FX http://openjfx.dev.java.net ● Your Name Here ● Sun Campus Ambassador Your Email Address Here


Download ppt "Scripting with Java FX Your Name Sun Campus Ambassador Your Address."

Similar presentations


Ads by Google