scalafx

ScalaFX - How to get the title of a Scene using a method

自作多情 提交于 2021-02-08 18:27:21
问题 I am using ScalaFX and trying to learn how it works. As an exerpiment (not what I will do in production) I want a method that gets the title of a window. So here is my Graph.scala file: package graphing import scalafx.application.JFXApp import scalafx.scene.Scene import scalafx.scene.paint.Color class Graph { val app = new JFXApp { stage = new JFXApp.PrimaryStage { title = "First GUI" scene = new Scene { fill = Color.Coral } } } def getTitle() = { app.stage.getTitle } def generateChart(args:

What's the magic behind ScalaFX to make OpenJDK 9+ actually work?

混江龙づ霸主 提交于 2020-06-24 22:18:46
问题 Environment : OpenJDK 64-Bit Server VM Zulu12.2+3-CA (build 12.0.1+12, mixed mode, sharing) Scala 2.12.7 Windows 10 Professional, X86_64 IntelliJ IDEA 2019.1.3 (Ultimate Edition) I checked out the scalafx-hello-world from GitHub, built and ran it in IntelliJ and it worked all fine. Here quickly the significant application implementation: package hello import scalafx.application.JFXApp import scalafx.application.JFXApp.PrimaryStage import scalafx.geometry.Insets import scalafx.scene.Scene

Scala name mangling of private fields and JavaFX FXML injection

☆樱花仙子☆ 提交于 2020-01-03 11:32:09
问题 The following example and explanations are quite long, so here is the gist of my question: how to deal with scalac's name-mangling of private fields when using a framework which insists on performing field injection (on fields which really should stay private)? I am writing an application in Scala, using ScalaFX/JavaFX and FXML. When you use FXML to define your views in JavaFX, objects defined in FXML (such as buttons and text fields) are injected into the controller by : adding an fx:id

Open and close JavaFx apps in scala console

二次信任 提交于 2019-12-31 04:41:08
问题 Here is an example: /* * Copyright 2013 ScalaFX Project * All right reserved. */ package scalafx.ensemble.example.charts import scalafx.application.JFXApp import scalafx.scene.Scene import scalafx.collections.ObservableBuffer import scalafx.scene.chart.LineChart import scalafx.scene.chart.NumberAxis import scalafx.scene.chart.XYChart /** A chart in which lines connect a series of data points. Useful for viewing * data trends over time. * * @see scalafx.scene.chart.LineChart * @see scalafx

A simplest scalafx example can't be compiled

本秂侑毒 提交于 2019-12-24 03:26:11
问题 I'm trying the scalafx with a simplest example, but it can't be compiled and the error is like: Error:scalac: bad symbolic reference to javafx.stage.PopupWindow.AnchorLocation encountered in class file 'StageIncludes.class'. Cannot access type AnchorLocation in object javafx.stage.PopupWindow. The current classpath may be missing a definition for javafx.stage.PopupWindow.AnchorLocation, or StageIncludes.class may have been compiled against a version that's incompatible with the one found on

ScalaFx: Event Handler with First Class Function

喜夏-厌秋 提交于 2019-12-23 07:38:51
问题 i try to write an event handler in a scalaFx app. I found followin solution: import scalafx.scene.control.ListView import javafx.scene.input.MouseEvent import javafx.event.EventHandler ... val list = new ListView[String] { onMouseClicked = new EventHandler[MouseEvent] { override def handle(event: MouseEvent) { doSomething(event) } } } But this seems to be very Java-style boilerplate code. Is there a way to do this with a first class function like this? onMouseClicked = (event: MouseEvent) =>

JavaFX KeyEvent.getText() returns empty?

╄→гoц情女王★ 提交于 2019-12-13 16:25:47
问题 According to the JavaDoc for KeyEvent 's getText() method, it returns A String describing the key code, such as "HOME", "F1" or "A", for key pressed and key released events. For key typed events, text is always the empty string. However, when I try printing getText() , it works as expected for printable characters, but not for other keys. "a" and "A" are the results for pressing the a and Shift-A keys, but pressing the Home, F1, or arrow keys results in "" . Similarly, it registers the

Compiling scalafx for Java 7u7 (that contains JavaFX 2.2) on OS X

主宰稳场 提交于 2019-12-13 14:24:57
问题 The compilation instructions of scalafx says to do: export JAVAFX_HOME=/Path/To/javafx-sdk2.1.0-beta sbt clean compile package make-pom package-src However, with the new packaging of JavaFX as part of the Java JDK itself (i.e. 7u7 for OS X) there no longer seems to be such a 'javafx-sdkx.x.x' folder. The Oracle docs say that JavaFX JDK is placed alongside the main Java JDK (in same folders). So I do: $ export JAVAFX_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk $ sbt clean [warn]

How does one combine ScalaFXML with Gradle?

时光怂恿深爱的人放手 提交于 2019-12-13 02:35:54
问题 Let me set up my end goal first: I want to build a scala only gui application, that I can design with scene builder and later port with gluon to any platform I want to. I was able to find out, that one needs to use JavaFXPorts in Scala to make that happen. I also found out that I need to use gradle to apply gluon successfully, or so it seems (please correct me if I am wrong because that's where the headache starts) So in short that means: ScalaFXML and Gradle need to work together, but how? I

scalafx.animation.Timeline not working as expected

心不动则不痛 提交于 2019-12-13 02:27:50
问题 I've started to try out the ScalaFX API few days ago. To learn the usage of this API I'm looking at the examples on GitHub. For testing out the features of the TimeLine class I used this example: ScalaFXAnimation. The code to define a TimeLine object is looking like this in the example: val timeline = new Timeline { cycleCount = Timeline.Indefinite autoReverse = true keyFrames = Seq( at (2 s) {rect1.x -> 200d tween Interpolator.EASE_IN}, at (4 s) {rect1.x -> 300d}, at (3 s) {rect2.y -> 100d