Scala Swing 中的微调器

发布于 2024-11-07 02:38:27 字数 339 浏览 0 评论 0原文

如何做到这一点: http://download.oracle.com/javase/tutorial/uiswing/components /spinner.html 使用: http://www.scala-lang.org/api/当前/index.html#package

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

稀香 2024-11-14 02:38:27

如果您想知道如何将 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)
    }
  }
}

If you're wondering how to add a JSpinner to a Scala swing application, you need to use Component.wrap(JComponent) to get a Scala component. This should give you something to model on:

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)
    }
  }
}
寂寞陪衬 2024-11-14 02:38:27

这并不容易。

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

It's not as easy.

[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 and javax.swing are conflicting. I think I should import only JSpinner class.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文