Created
September 23, 2011 17:55
-
-
Save hideaki-t/1238013 to your computer and use it in GitHub Desktop.
another custom browser using GroovyFX with JavaFX 2.0 build45+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovyx.javafx.GroovyFX | |
import groovyx.javafx.SceneGraphBuilder | |
import javafx.beans.value.ChangeListener | |
import static javafx.concurrent.Worker.State.SCHEDULED | |
import static javafx.concurrent.Worker.State.SUCCEEDED | |
GroovyFX.start({ | |
def sg = new SceneGraphBuilder(it) | |
def loadAction = { wv.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 = textField(onAction: loadAction, prefColumnCount: 60) | |
button(text: "Load", onAction: loadAction) | |
} | |
wv = webView( | |
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) | |
} | |
} | |
} | |
} | |
def engine = wv.engine | |
engine.load("http://www.yahoo.co.jp/") | |
engine.loadWorker.stateProperty().addListener({ t, o, n -> | |
switch (n) { | |
case SUCCEEDED: scrIn.playFromStart(); urlBox.text = engine.location; break | |
case SCHEDULED: scrOut.playFromStart(); break | |
} | |
} as ChangeListener) | |
// unable to input when urlBox bind to location | |
// urlBox.textProperty().bind(engine.locationProperty()) | |
stage.titleProperty().bind(engine.titleProperty()) | |
stage.show() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment