Scala Swing中的微调器

时间:2011-05-12 23:29:16

标签: swing scala spinner

2 个答案:

答案 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._

swingjavax.swing存在冲突。我想我应该只导入JSpinner类。