0

我对编程有点陌生,但我已经知道很多了。我一直停留在默认窗口中,但现在我无法用我知道的东西做我想做的事情。我正在尝试创建一个显示透明自定义窗口的类,它正在使用一个JFrame被调用CFrame但要设置它透明我必须使用:

try
{
    AWTUtilities.setWindowOpaque(CFrame, false);
}

catch(Exception ex)
{
    System.err.println("Failed to set CFrame Opaque");
}

但是由于有来自 Sun 的不同 JVM 的 AWTUtilities,因此无法正常工作。因此,如果有人知道如何解决我的问题或知道如何将组件和图像绘制到屏幕上,那将会很有帮助。

4

1 回答 1

3

If you can use Java 7, the window opacity stuff has been moved into the public API. See: http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html#uniform. Basically, there's now a setOpacity method in the Frame class, but the tutorial shows how to detect whether the graphics system even supports transparency, to "platform-proof" yourself.

As to general drawing with swing, there are stacks of tutorials on the web. Maybe start with this one: http://docs.oracle.com/javase/tutorial/uiswing/painting/step1.html. Even the related questions that pop up here are going to have a wealth of info.

The book Filthy Rich Clients is really good for advanced swing UIs.

于 2012-06-02T02:15:48.263 回答