Created
July 1, 2015 12:19
-
-
Save halcat0x15a/68261325ac922556b0cd to your computer and use it in GitHub Desktop.
This file contains 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 javafx.application.Application | |
import javafx.event.EventHandler | |
import javafx.scene.input.MouseEvent | |
import javafx.stage.Stage | |
import javafx.scene.{Scene, Group} | |
import javafx.scene.control.Button | |
import scalaz.concurrent.Future | |
class GUI extends Application { | |
def start(stage: Stage) = { | |
val button = new Button("Click Me") | |
val point = Future.async[(Double, Double)] { listen => | |
button.setOnMouseClicked(new EventHandler[MouseEvent] { | |
def handle(event: MouseEvent) = listen((event.getScreenX, event.getScreenY)) | |
}) | |
} | |
point.runAsync(println) | |
val scene = new Scene(new Group(button)) | |
stage.setScene(scene) | |
stage.sizeToScene() | |
stage.show() | |
} | |
} | |
object GUI extends App { | |
Application.launch(classOf[GUI]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment