Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swing 斯卡拉秋千中的旋转器_Swing_Scala_Spinner - Fatal编程技术网

Swing 斯卡拉秋千中的旋转器

Swing 斯卡拉秋千中的旋转器,swing,scala,spinner,Swing,Scala,Spinner,如何做到这一点: 使用它:?如果您想知道如何将JSpinner添加到Scala swing应用程序中,您需要使用Component.wrap(JComponent)来获取Scala组件。这应该会给你一些可以借鉴的东西: import swing._ import javax.swing.SpinnerListModel import javax.swing.JSpinner object SpinnerDemo extends SimpleSwingApplication { val m

如何做到这一点:
使用它:?

如果您想知道如何将
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)
    }
  }
}
这并不容易

[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
类。

我想你是想在yuor link:interest中指定swing包。我回答中的代码使用scala 2.9.0为我编译并正确运行。我将编辑我的答案,并使导入更紧密。