0

我正在查看一些在 scala 2.9.1 中出错的示例代码:

import javax.swing.JFrame
import javax.swing.JMenuBar
import javax.swing.JButton
import javax.swing._

import com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel
import javax.swing.{UIManager}
object UI extends SimpleSwingApplication {   
    UIManager.setLookAndFeel(new NimbusLookAndFeel)  
}

错误:/some/path/Cls.scala:25:错误:未找到:类型 SimpleSwingApplication

4

1 回答 1

1

原来我必须像这样运行我的代码:

scala -classpath /usr/share/java/scala-swing.jar Cls.scala

成功的代码库是:

import javax.swing.JFrame
import javax.swing.JMenuBar
import javax.swing.JButton
import javax.swing._
import scala.swing.SimpleSwingApplication
import scala.swing._


object UI extends SimpleSwingApplication {   
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())  
    def top = new MainFrame {
      title = "First Swing App"
      contents = new Button {
        text = "Click me"
      }
    }

    def main() {
        println("hi")
    }
}
于 2013-10-05T23:10:27.077 回答