å¤ä¼ã¿åã®å°ãã¿ã第2å¼¾ã
ä»æ¥ããããç®ã«ãããã¡ããè¦ã¦ã
Rubyã§GUIã¢ããªãä½ããªãJRuby+JavaFX+Rawrã§æ±ºã¾ãï¼
http://blog.supermomonga.com/articles/jruby/javafx-rawr.html
Scalaã¨Groovyã§ãJavaFXã使ã£ã¦åããããªãã¨ããã£ã¦ãã¾ããã
ããæåã«æ³¨æäºé ã
- ScalaFXãGroovyFXã¯ããããJavaFXã触ã£ããã¨ãªã人ãæ¸ãã¦ã¾ã
- ããã¾ã§ããåãç»é¢ãåºãã¾ã§ãã®ã¨ããããã£ãã ãã§ãexeãã¡ã¤ã«åã¨ãã¯ä¸åãã¼ã¿ããã§ã
ã¨ã¯ãããå°ãã ãJavaFXã«èå³ã¯ãã£ãã®ã§ãå¢ãã§ãããã¦ã¿ã¾ãããååãå ã«åºãã¡ããã¾ãããã©ãScalaFXã¨GroovyFXã§ã
ScalaFX
http://code.google.com/p/scalafx/
GroovyFX
http://groovyfx.org/
ã¨ããããã両æ¹ã¨ãGetting Startedã¨ããè¦ãªããâ¦ã
ScalaFX GettingStarted
http://code.google.com/p/scalafx/wiki/GettingStarted
GroovyFX Getting Started
http://groovyfx.org/docs/guide/gettingStarted.html
â¦ããããããªããå§åçã«ããã¥ã¡ã³ãä¸è¶³ã
ã¾ããGetting Startedã®ä»ã«ãµã³ãã«ã¨ãããªãã¸ããªã®ã½ã¼ã¹ã¨ããè¦ãªããé°å²æ°ã§å®è£ ããã¨ããã¡ãã«ã軽ãç®ãéãã¦ã
JavaFX 2 API
http://docs.oracle.com/javafx/2/api/index.html
ãã使ã£ã¦ããJavaã®ãã¼ã¸ã§ã³ã¯ãã¡ãã§ãã
$ java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
ã§ã¯ãæ¸ããã³ã¼ãã¨çµæãã
ScalaFX
ãã«ãã«ã¯ãsbtã使ç¨ãã¾ããã
build.sbt
name := "scalafx-getting-started" version := "0.0.1-SNAPSHOT" scalaVersion := "2.10.2" organization := "littlewings" fork in run := true unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/jre/lib/jfxrt.jar")) libraryDependencies += "org.scalafx" %% "scalafx" % "1.0.0-M4"
jfxrt.jarã«unmanagedJarã¨ãã¦ãã¹ãéãã¦ããã¨ãããããã¤ã³ãã®ããã§ãããã¨ãfork in runãtrueã«ãã¦ãããªãã¨ã2åç®ä»¥éã®å®è¡ã§
Caused by: java.lang.UnsatisfiedLinkError: Native Library /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libglass.so already loaded in another classloader
ã¿ãããªãã¨ãè¨ããã¦ãã³ã±ã¦ããã¾ãã
ã³ã¼ãæ¬ä½ã
src/main/scala/ScalaFXGettingStarted.scala
import scalafx.application.JFXApp import scalafx.scene.Scene import scalafx.scene.web.WebView object ScalaFXGettingStarted extends JFXApp { val browser: WebView = new WebView browser.engine.load("http://google.com") stage = new JFXApp.PrimaryStage { title = "Hello ScalaFX" width = 800 height = 600 scene = new Scene { root = browser } } }
å®è¡ã
> run [info] Running ScalaFXGettingStarted
GroovyFX
ç¶ãã¦ãGroovyFXããã¡ãã¯ãGrapeã使ç¨ãã¾ããã
groovyfx-getting-started.groovy
@Grab('org.codehaus.groovyfx:groovyfx:0.3.1') import static groovyx.javafx.GroovyFX.start start { stage(title: 'Hello GroovyFX', visible: true) { scene(width: 800, height: 600) { wv = webView() } } wv.engine.load('http://google.com/') }
çã£ï¼ï¼
å®è¡ã«ã¯ããã¡ããjfxrt.jarãå¿ è¦ãªã®ã§ãããããã¯æ®éã«cpãªãã·ã§ã³ã§ä»ãã¾ããã
$ groovy -cp $JAVA_HOME/jre/lib/jfxrt.jar groovyfx-getting-started.groovy
çµæã
åºã¾ãããã¼ã
ãªãã§ããã©ãScalaFXã¨GroovyFXã§åãheightãæå®ãã¦ããã§ããã©ããªããGroovyFXã®æ¹ãã¡ãã£ã¨å¤§ãããã§ããã©â¦ScalaFXãå°ããã®ãã©ããã¯ãããã¾ãããã
ã¨ãããããåãããããããããªï¼
両æ¹ã¨ããAPIãªãã¡ã¬ã³ã¹ããããªããã®ããªãâ¦ã