De la mano de Sun Microsystems, hace ya un tiempo, ha llegado JavaFX para competir en el mercado de las RIA (Rich Internet Application) con otros productos como Ms Silverlight o Adobe AIR.

Siguiendo los pasos del artículo Creating Rich Internet Applications With Compiled JavaFX Script Technology instalaremos el compilador, compilaremos y ejecutaremos el infaltable “Hola Mundo”.

  • Si no tenemos instalada la maquina virtual de Java, instalar el JR5 o superior
  • Descargar el JavaFX Script Compiler
  • Descomprimir archive.zip en path que desee, y agregar la variable de entorno \archive\openjfx-compiler\dist\bin (desde propiedades del sistema, o bien para la un consola ejecutando set Path=%Path%;”path\archive\openjfx-compiler\dist\bin”
  • Crear el archivo HolaMundo.Fx:
import javafx.ui.*;
import javafx.ui.canvas.*;

Frame {
  title: "JavaFX Rich Internet Applications"
  width: 550
  height: 200
  background: Color.WHITE
  visible: true
  content:
  BorderPanel {
    top:
      FlowPanel {
        content:
          Button {
            text: "Click aquí!"
            action:
              function(): Void {
                MessageDialog {
                  title: "JavaFX Script"
                  message: "JavaFX Script
es simple y elegante"
                  visible: true
               }
             }
         }
     }
   center:
     Canvas {
       content:
         Text {
           font:
             Font {
               faceName: "Sans Serif"
               style: FontStyle.BOLD
               size: 18
             }
             x: 30
             y: 30
             stroke: Color.BLUE 
             fill: Color.BLUE
             content: "JavaFX Script
hace el desarrollo de RIA más facil"
         } 
     }
  }
}
  • Compilar HolaMundo.Fx, ejecutando javafx HolaMundo.fx
  • Ejecutar la aplicación, javafx HolaMundo