Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 10 02:06

    jpsacha on stable

    Merge branch 'stable' Mark next development version Use scala versions provided in … and 28 more (compare)

  • May 08 01:40

    jpsacha on master

    Add attributions to 18.0.1-R27 … (compare)

  • May 08 01:32

    jpsacha on master

    Add release notes for 18.0.1-R27 Merge branch 'master' into stab… Add release notes for 18.0.1-R27 and 3 more (compare)

  • May 08 01:30

    jpsacha on v.18.0.1-R27

    Add release notes for 18.0.1-R27 Merge branch 'master' into stab… Add release notes for 18.0.1-R27 and 1 more (compare)

  • May 07 18:10
    jpsacha labeled #371
  • May 07 18:08
    jpsacha closed #363
  • May 07 18:08

    jpsacha on master

    Update JavaFX to 18.0.1 Update Scala 3.1 to 3.1.2 Update scalafmt to v.3.5.2 and 1 more (compare)

  • Apr 23 20:31
    jpsacha closed #376
  • Apr 14 02:02

    jpsacha on master

    Ignore DS_Store files (compare)

  • Mar 27 00:08
    jpsacha commented #378
  • Mar 26 21:36
    Hungreeee closed #378
  • Mar 26 21:36
    Hungreeee commented #378
  • Mar 26 19:32
    jpsacha commented #378
  • Mar 26 19:16
    Hungreeee commented #378
  • Mar 23 00:39

    jpsacha on master

    Add working example from issue … (compare)

  • Mar 23 00:36
    jpsacha commented #378
  • Mar 23 00:29
    jpsacha labeled #378
  • Mar 23 00:24
    jpsacha commented #210
  • Mar 22 20:36
    Hungreeee opened #378
  • Mar 22 18:40
    jpsacha milestoned #377
BaghdadKh
@BaghdadKh
Hi , does scala-fx works with android and scala-js ?
Romain DEP.
@rom1dep
BaghdadKh: Hi! ScalaFX, as the name implies, is a Scala DSL for the JavaFX application framework. On android, the scala compat isn't terrific, due to android's only supporting old javas, maybe you will be able to use the fx-ports provided by gluonhq, and build a scalafx app on android using an ancient scala, but I doubt the experience will be great.
Gluon also is working on a separate JVM for android, which promises compat with newer javas (and I assume scalas), but I don't know where it's at.
JavaFX doesn't have javascript bindings, so I don't see how that would make sense to compile to JS and expect a JavaFX app in return, bit if you were to compile a JavaFX app for the web, you can have a look at jpro.one (never tried it)
Etturaz
@Etturaz
Hello. Very really newbie question: how do I use javafx themes such as bootstrapFx, gluon dark, &c. in ScalaFX?
Joerg von Roos
@jvr-ks

`
/*
// the file build.sbt:

scalaVersion := "2.12.9"

// https://mvnrepository.com/artifact/org.scalafx/scalafx
libraryDependencies += "org.scalafx" %% "scalafx" % "11-R16"

// https://mvnrepository.com/artifact/org.kordamp.bootstrapfx/bootstrapfx-core
libraryDependencies += "org.kordamp.bootstrapfx" % "bootstrapfx-core" % "0.2.4"

mainClass in (Compile,run) := Some("Bootstrapfx")

*/

// the file bootstrapfx.scala

import scalafx.Includes._
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.stage.Stage
import scalafx.scene.Scene
import scalafx.scene.layout.BorderPane
import scalafx.scene.control.Button

import org.kordamp.bootstrapfx.scene.layout._

object Bootstrapfx extends JFXApp {
stage = new PrimaryStage {
width = 800
height = 600

    scene = new Scene() {
        val button = new Button("Hello BootstrapFX")

        button.onAction = handle {
            stage.close()
        }
        button.getStyleClass().setAll("btn","btn-danger")
        root = new BorderPane() {
            center = button
        }
        stylesheets = List(getClass.getResource("org/kordamp/bootstrapfx/bootstrapfx.css").toExternalForm)
    }

}

stage.setTitle("BootstrapFX")

stage.show()

}

// to start: sbt run

`

Joerg von Roos
@jvr-ks
stage.show() is redundant
Joerg von Roos
@jvr-ks
does not run as scala-script
this runs as scala script, but not in the sbt console:
// this file bootstrapfx.scala

// jar file from https://mvnrepository.com/artifact/org.kordamp.bootstrapfx/bootstrapfx-core
// lib/bootstrapfx-core-0.2.4.jar

// jar file from https://mvnrepository.com/artifact/org.scalafx/scalafx
// lib/scalafx_2.12-12.0.2-R18.jar

// Java 8


// windows batchfile "run.bat" to run as scala-script:
/*
@rem add all *.jar in lib subdirectory to classpath

@echo off
set clp=.
for %%c in (lib/*.jar) do call :Setclasspath %%c
cmd /c scala -cp %clp% -savecompiled bootstrapfx.scala
exit /B %ERRORLEVEL%

:Setclasspath
set clp=%clp%;lib/%~1
exit /B 0

*/*/


import scalafx.Includes._
import scalafx.application.Platform
import scalafx.application.JFXApp
import scalafx.application.JFXApp.PrimaryStage
import scalafx.stage.Stage
import scalafx.scene.Scene
import scalafx.scene.layout.BorderPane
import scalafx.scene.control.Button

import java.util.concurrent
import org.kordamp.bootstrapfx.scene.layout._


val app = new JFXApp {
  def op = {
    stage = new PrimaryStage {
      width = 800
      height = 600

      scene = new Scene() {
        val button = new Button("Hello BootstrapFX")

        button.onAction = handle {
          stage.close()
          Platform.exit()
        }
        button.getStyleClass().setAll("btn", "btn-danger")
        root = new BorderPane() {
          center = button
        }
        stylesheets = List(getClass.getResource("org/kordamp/bootstrapfx/bootstrapfx.css").toExternalForm)
      }
    }
    stage.setTitle("BootstrapFX")
  }

  def onFXAndWait[R](op: => R): R = {
    if (Platform.isFxApplicationThread) {
      op
    } else {
      val callable = new concurrent.Callable[R] {
        override def call(): R = op
      }
      val future = new concurrent.FutureTask(callable)
      Platform.runLater(future)
      future.get()
    }
  }

  onFXAndWait[Unit](op)

  stage.show()
}

app.main(Array(""))
Spekular
@Spekular
Hi!
I'm getting a compilation error when I try to use Screen.getOutputScaleX ("not a member of scalafx.stage.Screen") on my desktop. However, on my laptop the code compiles fine. It looks to me like this function was introduced in Java 9, so my hunch is that for some reason my desktop is using JavaFX 8. I can't seem get sbt to build with a newer version though, and I can't even find where the old version would be installed to.

Here's my:
build.sbt (directly in the project folder)

calacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature")

// Fork a new JVM for 'run' and 'test:run', to avoid JavaFX double initialization problems
fork := true

//Allows command line version to take input
connectInput in run := true

resolvers += Resolver.sonatypeRepo("snapshots")

// Add dependency on ScalaFX library
libraryDependencies += "org.scalafx" %% "scalafx" % "12.0.2-R18"

// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
  case n if n.startsWith("Linux")   => "linux"
  case n if n.startsWith("Mac")     => "mac"
  case n if n.startsWith("Windows") => "win"
  case _ => throw new Exception("Unknown platform!")
}

lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
libraryDependencies ++= javaFXModules.map( m =>
  "org.openjfx" % s"javafx-$m" % "12.0.2" classifier osName
)

//Hopefully let assembly jars build?
assemblyMergeStrategy in assembly := {
 case PathList("META-INF", xs @ _*) => MergeStrategy.discard
 case x => MergeStrategy.first
}

libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.2.0"

build.properties (under "project" folder)

sbt.version=1.3.10

plugins.sbt (under "project" folder)

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
Spekular
@Spekular
I'm using sbt version 1.3.10, and the Scala version on my desktop is 2.12.7.400, but unless I'm mistaken sbt should grab a version that matches it's own?
Laptop has no standalone Scala install and is on sbt version 1.2.8
However, since the project is synced between the two sbt.version=1.3.10 should apply there as well.
Spekular
@Spekular
Fixed, there were some remnants of Java 1.8 that I had to delete to get it to use 1.12 (deleted the entire C:\Program Files (x86)\Common Data\Oracle\Java folder)
DavidGoodenough
@DavidGoodenough
Is there a way with fx-9+ to build all three os versions with sbt in one run, and name the results to include the os name?
Will Paul
@dropofwill
Anyone manage to get scalafx building a graal native-image? I've been playing Gluon's substrate which works fine for Java, but haven't been able to get it to work with classes from Scala.
Daniele Tentoni
@Daniele-Tentoni
Hi all I'm a student from Italy and pretty new to Scala development, what library you use to test scalafx applications?
Romain DEP.
@rom1dep
@dropofwill hi! FYI there's been a new release of graalvm/native-image, maybe you'll get more luck with it?
Leon Burdinov
@leonbur

Hello everyone. I'm trying to use SBT's ~run to reload changes to the code but it doens't work in ScalaFX projects. even the basic example from Scala Tutorials doesn't work and it has fork := true in build.sbt

did you encounter this?

Rohan Sircar
@rohan-sircar
@leonbur you can try DCEVM instead for hot code reload in JVM apps.
Leon Burdinov
@leonbur
@rohan-sircar I will but do you have any idea why SBT fails on this?
Rohan Sircar
@rohan-sircar
@leonbur Unfortunately not. I'd need more detail/to look at the error at the very least.
Leon Burdinov
@leonbur
there is no error though. here's an example of the simplest project: https://github.com/scalafx/ScalaFX-Tutorials/tree/master/hello-sbt
if you can please run with SBT and see for yourself
if I change the code and save, it's only when I close the first instance of the application that SBT loads right away a new instance with the changes
it really felt like fork := true would solve this. it looks just like that behaviour
Rohan Sircar
@rohan-sircar
Yeah I expected that, I've had that happen with a spring boot + javafx project as well, it's not an sbt specific issue. It's probably because javafx blocks the "application" preventing sbt from restarting it.
Like, it also happens when I run ammonite in sbt ~console. The console reloads only when I exit ammonite.
As I said, at least as far as GUI's are concerned DCEVM is the way to go.
Leon Burdinov
@leonbur
@rohan-sircar I see. thank you very much!
Rohan Sircar
@rohan-sircar
As a bonus, for best results -
1) Download DCEVM from here https://github.com/TravaOpenJDK/trava-jdk-11-dcevm/releases
2) Start Intellij and your app with that JVM
3) Run your app in intellij in debug mode
Leon Burdinov
@leonbur
thanks! I was starting looking at intelliJ plugins
for DCEVM
Romain DEP.
@rom1dep
scalafx is so much more pleasing to read with Scala 3's braceless syntax
Rohan Sircar
@rohan-sircar
Wait, it's updated to scala 3 already?
Romain DEP.
@rom1dep
image.png
well… :)
quite happy that my codebase built against scala3 with only minor changes
Rohan Sircar
@rohan-sircar
damn, gotta try it asap
Romain DEP.
@rom1dep
I also don't miss putting new everywhere
ankusharya
@ankusharya
Any help of changing scene in scalafx. i have setup PrimaryStage. Any blog or little guidance will help. Thanks
Jarek Sacha
@jpsacha
@ankusharya a stage, like PrimaryStage, has property scene if you want to have new scene you create a new one and assign to that property
Dennis Agostinho da Silva
@prolific-dev

Evening everyone,

I'm new to ScalaFX and I wonder if I am able to use and import a fxml file with the newest version in the meanwhile without implicit using the JavaFx lib, since all google searches directed me to answers from about 7-9 year agos, where the answer was "no". I'm thankful for some tips or even links where the topic gets explained.

Thank you.

Jarek Sacha
@jpsacha
You can use FXML with any version of ScalaFX and any version of Scala. You can do it using typical verbose JavaFX-way - example of that is here: https://github.com/scalafx/ProScalaFX/tree/master/src/proscalafx/ch10/fxml
Jarek Sacha
@jpsacha
@prolific-dev there are two libraries that simplify use of FXML from ScalaFX: ScalaFXML and ScalaFX Extras. ScalaFXML can only be used with Scala 2, ScalaFX Extras with Scala 2 and Scala 3
There is an example of using ScalaFXML, in addition to documentation on its website, here: https://github.com/scalafx/ScalaFX-Tutorials/tree/master/scalafxml-example
Jarek Sacha
@jpsacha
The main example of using ScalaFX Extras MVCfx pattern is in the demos project, look for the StopWatch example