Skip to content

Instantly share code, notes, and snippets.

@hideaki-t
Created July 23, 2011 05:18
Show Gist options
  • Save hideaki-t/1101054 to your computer and use it in GitHub Desktop.
Save hideaki-t/1101054 to your computer and use it in GitHub Desktop.
another custom browser using GroovyFX with JavaFX 2.0 build36+
import groovyx.javafx.GroovyFX
import groovyx.javafx.SceneGraphBuilder
import javafx.beans.value.ChangeListener
import static javafx.concurrent.Worker.State.*
GroovyFX.start({
def sg = new SceneGraphBuilder(it)
def engine = sg.webEngine()
def loadAction = { engine.load(new URL(urlBox.getText()) as String) }
def stage = sg.stage(title: "GroovyFXのテスト") {
scene(width: 800, height: 600) {
vbox(spacing: 10, layoutY: 10) {
hbox(spacing: 10, alignment: "center") {
urlBox = textBox(columns: 40, action: loadAction, text: bind(source: engine, sourceProperty: 'location'))
button(text: "Load", onAction: loadAction)
}
webView(
engine: engine,
prefWidth: 800, prefHeight: 400,
translateX: 800,
effect: reflection()
) {
scrIn = translateTransition(fromX: 800, toX: 0, duration: 500.ms, interpolator: "ease_both")
scrOut = translateTransition(fromX: 0, toX: -800, duration: 500.ms)
}
}
}
}
engine.load("http://www.yahoo.co.jp/")
engine.loadWorker.stateProperty().addListener({ t, o, n ->
switch (n) {
case SUCCEEDED: scrIn.playFromStart(); break
case SCHEDULED: scrOut.playFromStart(); break
}
} as ChangeListener)
stage.titleProperty().bind(engine.titleProperty())
stage.visible = true
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment