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.

GroovyFX: or how to program JavaFX easily

3,598 views

Published on

An introduction to GroovyFX as the scripting language for JavaFX. JavaFX 1 had JavaFX Script, JavaFX 2 is just a Java API. GroovyFX steps up to the plate to be the scripting language for that API.

Published in: Technology
  • Be the first to comment

GroovyFX: or how to program JavaFX easily

  1. 1. GroovyFX or How to Program JavaFX Easily Prof Russel Winder http://www.russel.org.uk email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winderCopyright © 2013 Russel Winder 1
  2. 2. Interstitial Advertisement ?Copyright © 2013 Russel Winder 2
  3. 3. Java AWT AppletsCopyright © 2013 Russel Winder 3
  4. 4. Copyright © 2013 Russel Winder 4
  5. 5. Interregnum Java server-side onlyCopyright © 2013 Russel Winder 5
  6. 6. Flex SilverlightCopyright © 2013 Russel Winder 6
  7. 7. Copyright © 2013 Russel Winder 7
  8. 8. JavaFXCopyright © 2013 Russel Winder 8
  9. 9. JavaFX Script import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.text.Font; import javafx.scene.text.Text; Stage { title: "Hello World" width: 250 height: 80 scene: Scene { content: Text { font: Font { size: 24 } x: 10, y: 30 content: "Hello World." } } } http://en.wikipedia.org/wiki/JavaFX_ScriptCopyright © 2013 Russel Winder 9
  10. 10. Historical Context ● JavaFX ● Compete against: ● RIA framework ● Flex – JavaME ● Silverlight – JavaSE ● JavaFX ScriptCopyright © 2013 Russel Winder 10
  11. 11. JavaFX didnt really catch on…Copyright © 2013 Russel Winder 11
  12. 12. …despite JavaFX Script.Copyright © 2013 Russel Winder 12
  13. 13. Copyright © 2013 Russel Winder 13
  14. 14. Graphics Frameworks ● GTK, GObject: ● Glade ● Qt: ● Qt Designer ● Qt Quick/QML ● wxWidgets: ● wxGladeCopyright © 2013 Russel Winder 14
  15. 15. The New JavaFX ● JavaFX 2: ● Java API for Java SE. ● Eventually a replacement for Swing. ● SceneBuilder ● FXML JavaFX == JavaFX 2Copyright © 2013 Russel Winder 15
  16. 16. import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; Import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.Text; public class HelloWorld extends Application { @Override public void start(final Stage stage) { stage.setTitle("Hello World"); final Group rootNode = new Group(); final Text textNode = new Text(10, 30, "Hello World."); textNode.setFont(Font.font("Ocean Sans MT", 24)); rootNode.getChildren().add(textNode); final Scene sceneNode = new Scene(rootNode, 250, 80); sceneNode.setFill(Color.web(“#d0c4b0”)); stage.setScene(sceneNode); stage.show(); } public static void main(final String[] args) { launch(args); } }Copyright © 2013 Russel Winder 16
  17. 17. No JavaFX ScriptCopyright © 2013 Russel Winder 17
  18. 18. GroovyCopyright © 2013 Russel Winder 18
  19. 19. Jim Clark Dean Iverson Dierk König Andres Almiray Russel WinderCopyright © 2013 Russel Winder 19
  20. 20. GroovyFX import static groovyfx.javafx.GroovyFX.start import javafx.scene.paint.Color start { stage title: Hello World, visible: true, { scene width: 250, height: 80, fill: Color.web(#d0c4b0), { text x: 10, y: 30, text: Hello World., font: 24pt "Ocean Sans MT" } } }Copyright © 2013 Russel Winder 20
  21. 21. Real Code http://nighthacking.comCopyright © 2013 Russel Winder 21
  22. 22. Having Good Architectures ● Separate concerns. ● Code for structure and ● MVC (model, view logic. controller), MVP (model ● CSS (cascading style view presenter). sheets) for presentation. ● Mediator. ● Façade.Copyright © 2013 Russel Winder 22
  23. 23. More code…Copyright © 2013 Russel Winder 23
  24. 24. http://griffon.codehaus.org/Copyright © 2013 Russel Winder 24
  25. 25. Interstitial Advertisement ?Copyright © 2013 Russel Winder 25
  26. 26. GroovyFX or How to Program JavaFX Easily Prof Russel Winder http://www.russel.org.uk email: russel@winder.org.uk xmpp: russel@winder.org.uk twitter: @russel_winderCopyright © 2013 Russel Winder 26

×