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
精彩评论