【问题标题】:swing issues in scalascala中的摇摆问题
【发布时间】:2013-10-05 23:02:12
【问题描述】:

我正在查看一些在 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

【问题讨论】:

    标签: swing scala scala-swing


    【解决方案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")
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 2012-11-20
      • 1970-01-01
      • 2012-04-20
      • 2012-10-29
      • 1970-01-01
      相关资源
      最近更新 更多