在Scala的Swing Frame上指定一个框架图标 [英] Specifying a frame icon on Scala’s Swing Frame

查看:76
本文介绍了在Scala的Swing Frame上指定一个框架图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Scala的 scala.swing.Frame 类中设置新的框架图标? Frame.iconImage:Image Frame.iconify()背后的意图是什么?我无法弄明白,他们正在做什么。

How can you set a new frame icon on Scala’s scala.swing.Frame class? What are the intentions behind Frame.iconImage: Image and Frame.iconify()? I can’t figure out, what they’re doing.

这是我的最后一次尝试

import scala.swing.Frame

class MyFrame extends Frame {
  iconImage = toolkit.getImage("src/main/resources/icon.png")
  visible = true
}

我还尝试了其他几种方法,但没有任何效果。

I also tried several other methods, but nothing worked.

推荐答案

我猜你是在OS X.可悲的是,图标装饰不适用于OS X的外观和感觉,它既不适用于Nimbus的外观和感觉,似乎没有特定的窗口装饰(使用OS X的标题栏)。

I'm guessing you are on OS X. Sadly, the icon decoration does not work for the OS X look and feel, neither does it work for Nimbus look and feel which seems to not come with a specific window decoration (uses title bar from OS X).

所以你需要看一下感觉它确实绘制了自己的窗口标题栏:

So you will need a look and feel that does paint its own window title bar:

import scala.swing._
import javax.swing._
UIManager.setLookAndFeel(new plaf.metal.MetalLookAndFeel)
JFrame.setDefaultLookAndFeelDecorated(true)

val f = new Frame {
   iconImage = toolkit.getImage(new java.net.URL(
      "http://www.scala-lang.org/sites/default/files/favicon.gif"))
   size = new Dimension(200, 200)
   visible = true
}

OS X窗口标题栏的唯一机会是如果你想用特定文件的默认图标进行装饰。

The only chance with OS X window title bars is if you want to decorate with the default icon used for a particular file.

在这里寻找 Window.documentFile http:// developer。 apple.com/library/mac/#technotes/tn2007/tn2196.html#//apple_ref/doc/uid/DTS10004439

这篇关于在Scala的Swing Frame上指定一个框架图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆