将 Java 组件添加到 Scala swing 面板
嗯,我正在尝试让 Java3D 在 Scala 中工作。我注意到 Canvas3D
是一个 Component
派生类,而 scala.swing
类仅允许 Swing 组件,或者ScalaComponent
或 JComponent
。这是我的代码:
object HelloUniverse extends SimpleSwingApplication {
def top = new MainFrame {
title = "Java3D with Scala"
contents = new BorderPanel {
val config = SimpleUniverse.getPreferredConfiguration()
val canvas = new Canvas3D(config)
peer.add(canvas, "Center")
}
}
}
是的,通过 .peer
方法,我得到了底层的 JPanel
。但是我该如何在其中添加重量级组件呢?
感谢您的帮助。
Well, I am trying to get Java3D working in Scala. I came to notice that the Canvas3D
is a Component
derived class, whereas the scala.swing
classed only allow for, well, swing components, either ScalaComponent
or JComponent
. Here would be my code:
object HelloUniverse extends SimpleSwingApplication {
def top = new MainFrame {
title = "Java3D with Scala"
contents = new BorderPanel {
val config = SimpleUniverse.getPreferredConfiguration()
val canvas = new Canvas3D(config)
peer.add(canvas, "Center")
}
}
}
So yeah, with the .peer
method I get the underlying JPanel
. But how would I add a heavyweight component in there?
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 JCanvas3D。它基于 JPanel。
更多信息请访问 http: //download.java.net/media/java3d/javadoc/1.5.0/com/sun/j3d/exp/swing/JCanvas3D.html
Try using JCanvas3D. It is based on JPanel.
More info at http://download.java.net/media/java3d/javadoc/1.5.0/com/sun/j3d/exp/swing/JCanvas3D.html
ScalaCanvas3D API 提供用于重量级和轻量级 Java 3D 渲染的 Scala Swing 组件。有关更多详细信息、示例程序和下载,请参阅“Java 3D 与 Scala”:http://www.interactivemesh.org/testspace/j3dmeetsscala.html
The ScalaCanvas3D API provides Scala Swing components for heavyweight and lightweigth Java 3D rendering. See 'Java 3D meets Scala' for more details, sample programs, and downloads : http://www.interactivemesh.org/testspace/j3dmeetsscala.html