如何做到这一点: http://download.oracle.com/javase/tutorial/uiswing/components/spinner.html 使用它:http://www.scala-lang.org/api/current/index.html#package?
答案 0 :(得分:2)
如果您想知道如何将JSpinner
添加到Scala swing应用程序,则需要使用Component.wrap(JComponent)来获取Scala组件。这应该给你一些模型:
import swing._
import javax.swing.SpinnerListModel
import javax.swing.JSpinner
object SpinnerDemo extends SimpleSwingApplication {
val monthStrings: Array[Object] = Array("January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December")
def top = new MainFrame {
title = "Spinner Demo"
val monthModel = new SpinnerListModel(monthStrings)
val spinner = new JSpinner(monthModel)
contents = new FlowPanel {
contents += new Label("Month")
contents += Component.wrap(spinner)
}
}
}
答案 1 :(得分:0)
这并不容易。
[error] /home/ciembor/projekty/VirtualCut/src/main/scala/View/View.scala:22: reference to Action is ambiguous;
[error] it is imported twice in the same scope by
[error] import javax.swing._
[error] and import swing._
swing
和javax.swing
存在冲突。我想我应该只导入JSpinner
类。