简体   繁体   中英

Scala gui doesn't work

I am trying to create a gui in scala but it has problems, although I added the dependencies:

libraryDependencies += "org.scala-lang.modules" % "scala-swing_2.11" % "1.0.1"

in the build.sbt file.

Here is a known simple code:

import scala.swing._

object FirstSwingApp extends SimpleGUIApplication {
  def top = new MainFrame {
    title = "First Swing App"
    contents = new Button {
      text = "Click me"
    }
  }
}

The compiler asks for GraphicsConfiguration parameter for MainFrame - but I think it gets no parameter...

As @edi points out, SimpleGUIApplication has been deprecated ages ago. In fact that trait does not exist any longer, as you can see in the API docs .

So your code cannot possibly compile under Scala 2.11. Perhaps you are using an old Scala version? Then you should't try to link to a library (Swing module) compiled against Scala 2.11.

You can ensure that by using sbt's %% artifact operator:

scalaVersion := "2.11.5"

libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "1.0.1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM