开发者

Is there a way to use AWTUtilities on JRuby?

开发者 https://www.devze.com 2023-02-22 13:46 出处:网络
I am trying to give a window in my desk app transparency. I\'ve come across the AWTUtilities method, setWindowOpacity(), 开发者_StackOverflow社区but I haven\'t been able to use it on my project. The l

I am trying to give a window in my desk app transparency. I've come across the AWTUtilities method, setWindowOpacity(), 开发者_StackOverflow社区but I haven't been able to use it on my project. The line import com.sun.awt.AWTUtilities does not seem to work.

Is there a way to use AWTUtilities on JRuby?

I have very little JRuby knowledge and even less Java. Thank you.


Just like any other Java class in JRuby, if you are using Sun JDK:

java_import 'com.sun.awt.AWTUtilities'

Here is an example:

require 'java'

java_import 'javax.swing.JFrame'
java_import 'javax.swing.JButton'
java_import 'com.sun.awt.AWTUtilities'

f = JFrame.new
f.add JButton.new('test')
f.title = 'title'
f.set_size(200,200)

AWTUtilities.set_window_opacity(f, 0.75)
f.visible = true
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号