Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JavaFX Mix

1,679 views

Published on

JUG Genova presentation on JavaFX technology

Published in: Technology
  • Be the first to comment

JavaFX Mix

  1. 1. Mixing Java and JavaFx Giampaolo Melis JUG Genova
  2. 2. Goal <ul><li>An MVC where Java is the controller and JavaFx the view. </li></ul>
  3. 3. Agenda <ul><li>JSR 223 Scripting for the Java Platform
  4. 4. The JavaFx Script language
  5. 5. Design and Programming Tools
  6. 6. Using Fx in a Java Application
  7. 7. Makeover of JhaarSearch Application
  8. 8. Resources
  9. 9. Q&A </li></ul>
  10. 10. JSR 223 Scripting for the Java Platform <ul><li>Framework for embedding scripts into Java source code. </li></ul>ClassLoader loader = Thread.currentThread().getContextClassLoader(); ScriptEngineManager manager = new ScriptEngineManager(loader); ScriptEngine engine = manager.getEngineByExtension( &quot;fx&quot; ); String script = &quot;println(&quot;Hello World!&quot;);&quot;; engine.eval(script);
  11. 11. The JavaFx Script language <ul><li>Primary component of the JavaFx platform for creating RIA. </li></ul><ul><li>Statically typed declarative scripting language, based on Java syntax. </li></ul><ul><li>Started as F3, has been changed from interpreted to compiled (fx compiler) version. </li></ul>
  12. 12. The JavaFx Script language <ul><li>Built in automatic binding.
  13. 13. Built in animation and effects.
  14. 14. Graphics primitives can be composed using CustomNode. </li></ul>import javafx.ui.*; import javafx.ui.canvas.*; Group { content: [Text { content: 'Hello JavaFX' transform: scale(4.0,4.0) }] } Hello JavaFX
  15. 15. Design and Programming Tools <ul><li>Many tools helping developers and designers </li><ul><li>JavaFx Pad
  16. 16. JavaFx Tutorial
  17. 17. Netbeans Plugin
  18. 18. SVG Converter
  19. 19. Project Nile </li></ul></ul>Demo ...
  20. 20. Using Fx in a Java Application <ul><li>The proxy method... </li></ul>public class FXDesktopControllerInvocationHandler implements InvocationHandler { Value delegate; public FXDesktopControllerInvocationHandler(Value delegate) { this.delegate = delegate; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String mname = method.getName(); if (mname.equals(&quot;toString&quot;)) return delegate.toString(); Type t = delegate.getType().getOperation(mname); Value v = t.instantiate(); v.setAttribute(&quot;this&quot;, delegate); Iterator<Attribute> i = v.getAttributes(); int c = 0; if (i.hasNext()) i.next(); while (i.hasNext()) { Attribute attribute = i.next(); if (args.length > c) v.setAttribute(attribute.getName(), args[c++]); } v.call(); return null; } }
  21. 21. Makeover of JhaarSearch Application Demo ...
  22. 22. Resources <ul><li>Chris Oliver's Weblog </li><ul><li>http://blogs.sun.com/chrisoliver/ </li></ul><li>OpenJFX Project </li><ul><li>https://openjfx.dev.java.net/ </li></ul><li>PlanetJFX Wiki </li><ul><li>http://jfx.wikia.com/wiki/Planet_JFX_Wiki </li></ul><li>JavaFX Main site </li><ul><li>http://javafx.com/ </li></ul></ul>
  23. 23. Q&A Any Questions? [email_address]

×