简体   繁体   English

Scala和Swing GUI应用程序

[英]Scala and Swing GUI applications

From reading parts of the Programming in Scala book, I realize that Scala can work with the Java Swing components to create GUI applications. 通过阅读Scala编程书中的部分内容,我意识到Scala可以使用Java Swing组件来创建GUI应用程序。

My question is if there are any projects or released applications (that are more than just simple examples) that use Scala and Swing? 我的问题是,是否有任何使用Scala和Swing的项目或已发布的应用程序(不仅仅是简单的示例)?

Is this because you wish to see some actual Scala Swing code, or are you just interested as to whether Scala Swing is "production-ready" ? 这是因为您希望看到一些实际的Scala Swing代码,或者您只是对Scala Swing是否“生产就绪”感兴趣? If it is the latter, Scala Swing is pretty good: I've started using it for all GUI code. 如果是后者,Scala Swing非常好:我已经开始将它用于所有GUI代码。 Compare: 相比:

JButton b = new JButton();
b.setText("OK");
b.setFont(f);
b.setPreferredSize(new Dimension(20, 20));
b.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      //reacction here
    }
});

with: 有:

val b = new Button {
  text = "OK"
  font = f
  preferredSize = (20, 20)
}
listenTo(b)
reactions += {
  case ButtonClicked(`b`) => //reaction here
}

As Scala Swing is really just a lightweight layer on top of Java Swing, you can integrate any Java Swing component easily and be sure that it all works OK. 由于Scala Swing实际上只是Java Swing上的一个轻量级层,因此您可以轻松地集成任何Java Swing组件,并确保它一切正常。

That said, the documentation as of Scala 2.7 is pretty poor. 也就是说,Scala 2.7的文档很差。 I understand that Scala Swing is being upgraded in the 2.8 release and that this will include improved documentation. 据我所知,Scala Swing正在2.8版本中进行升级,这将包括改进的文档。

House of Mirrors 镜子之家

I have written this game in Scala. 我在斯卡拉写过这个游戏 It's open-source and uses Swing via both the Java and Scala library interfaces. 它是开源的,并通过Java和Scala库接口使用Swing。

The Scala API is great to work with as oxbox_lakes illustrated. Scala API很适合用作图示的oxbox_lakes。 I had to use the Java interface only for specific low level control such as custom alpha composition. 我不得不将Java接口仅用于特定的低级别控制,例如自定义alpha合成。

Before the Scala-swing library had become stable, the game was based on Scala-Squib , but that project has paused AFAIK. 在Scala-swing库稳定之前,该游戏基于Scala-Squib ,但该项目暂停了AFAIK。

在Google代码中有Scalide ,然后Scala本身就有Swing

I attended a talk recently on Scala and one of the products demo-ed was a Scala-Swing Twitter client. 我最近参加了一个关于Scala的演讲,其中一个产品demo-ed是一个Scala-Swing Twitter客户端。 It is open-source and the project is TalkingPuffin . 它是开源的,项目是TalkingPuffin The UI looked pretty slick for a Swing project and I believe the project is looking for contributors. 对于Swing项目,UI看起来很漂亮,我相信该项目正在寻找贡献者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM