java 7中是否可以有一个包含标题栏的半透明窗口? [英] Is it possible to have a translucent windows in java 7 including a title bar?

查看:23
本文介绍了java 7中是否可以有一个包含标题栏的半透明窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与这个问题有关:是Java教程半透明窗口示例那些玩jdk7的人有麻烦吗?

对于 jdk1.6.0_26,我似乎能够将半透明应用于 JFrame,但对于 jre7 则不然:

NativeException: java.awt.IllegalComponentStateException: 框架被装饰

ex(jruby 脚本 java,但 jdk1.6 不适用于 jdk7):

<上一页>需要'java'类 MouseDrawdef self.gojava_import 'javax.swing.JFrame'java_import 'com.sun.awt.AWTUtilities'f = JFrame.newAWTUtilities.set_window_opacity(f, 0.5)f.set_size 200,200f.show结尾结尾MouseDraw.go

所以我的问题是jdk7 中是否可以有一个半透明的标题栏"(我希望我创建的透明窗口可以拖动/调整大小)

解决方案

Java 7 引入 Window.setOpacity() 来做 Java 6 中非官方类 AWTUtilities 所做的事情.

不幸的是,它被证明不能使用装饰过的窗户:

<块引用>

要设置不透明度值小于1.0f,必须满足以下条件:

(强调我的)

Related to this question: Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?

with jdk1.6.0_26 I seem to be able to apply translucency to a JFrame, but not so with jre7:

NativeException: java.awt.IllegalComponentStateException: The frame is decorated

ex (jruby scripting java, works jdk1.6 not with jdk7 though):


require 'java'

class MouseDraw

  def self.go
    java_import 'javax.swing.JFrame'
    java_import 'com.sun.awt.AWTUtilities'

    f = JFrame.new
    AWTUtilities.set_window_opacity(f, 0.5)
    f.set_size 200,200
    f.show
  end

end
MouseDraw.go

So my question is "is it possible to have a translucent title bar in jdk7" (I would like a transparent window I'm creating to be draggable/resizable)

解决方案

Java 7 introduced Window.setOpacity() to do what the unofficial class AWTUtilities did in Java 6.

Unfortunately it's documented not to work with decorated windows:

The following conditions must be met in order to set the opacity value less than 1.0f:

(Emphasis mine)

这篇关于java 7中是否可以有一个包含标题栏的半透明窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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