Skip to content

Instantly share code, notes, and snippets.

@halcat0x15a
Created July 1, 2015 12:19
Show Gist options
  • Save halcat0x15a/68261325ac922556b0cd to your computer and use it in GitHub Desktop.
Save halcat0x15a/68261325ac922556b0cd to your computer and use it in GitHub Desktop.
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