我应该关注使用AWTUtilities.setWindowShape()吗? [英] Should I be concerned using AWTUtilities.setWindowShape()?

查看:576
本文介绍了我应该关注使用AWTUtilities.setWindowShape()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用 AWTUtilities 类来创建自定义窗口形状。据我所知,没有别的办法可以做到。这是一个要求。

I am using the AWTUtilities class in my application to create custom window shapes. As far as I know, there is no other way to do it. It is a requirement.

javadoc生成给了我这个错误:

The javadoc generation gives me this error:


警告:com.sun.awt.AWTUtilities是Sun专有API,可能会在将来的版本中删除

warning: com.sun.awt.AWTUtilities is Sun proprietary API and may be removed in a future release

这究竟是什么意思?我可以使用它,但它可能会停止使用任何版本?为什么要把它放进去呢?更重要的是,这里真正的问题是,如果Sun将其取出,他们是否可能会采用另一种方式来替换它?这是警告的用途吗?

What exactly does this mean? I can use it, but it may stop working with any release? Why put it in, then? More importantly, and the real question here, if Sun takes it out, will they likely replace it with another way to do the same thing? Is that what the warning is for?

我想我可以在调用代码之前检查是否存在AWTUtilities类。但如果我不需要这样做,那就太讨厌了。

I suppose I could just check for the presence of the AWTUtilities class before calling the code. But that's just obnoxious if I don't need to do it.

有没有人有类似课程的经验?他们最终是否被API接受并且警告被删除或替换为另一种做同样事情的方法?我需要关注这个吗?

Does anyone have any experience with similar classes? Were they eventually accepted into the API and the warning removed or replaced with another method of doing the same thing? Do I need to be concerned about this?

仅供参考,我读过这个:

FYI, I have read this:

如何分发AWTUtilities

推荐答案

Oracle 文档声明:

The Oracle documentation states:


注意:com.sun.awt.AWTUtilities类不是官方支持的API的一部分,而是作为实现细节显示。 API仅适用于核心平台之外的有限使用。它可能会在更新版本之间发生巨大变化,甚至可能会被删除或移动到其他一些包或类中。该类应该通过Java Reflection使用。支持的公共API将出现在下一个主要的JDK版本中。

Note: the com.sun.awt.AWTUtilities class is not part of an officially supported API and appears as an implementation detail. The API is only meant for limited use outside of the core platform. It may change drastically between update releases, and it may even be removed or be moved in some other packages or classes. The class should be used via Java Reflection. Supported and public API will appear in the next major JDK release.

JDK 7已经很长时间了,所以可能需要一段时间。您是否应该使用它是一个风险管理问题,只有贵公司才能回答。如果我们讨论的是可以保证部署的JRE的内部应用程序,那么您将不会遇到问题,因为您可以保证兼容的JRE。如果我们谈论部署到外部客户,那么如果这个临时API发生变化,你需要有一个支持计划。

JDK 7 has been a long time coming so it could be awhile. Whether you should use it is a risk management question that only your company can answer. If we are talking about an internal application where the deployed JRE can be guaranteed then you are not going to have a problem because you can guarantee a compatible JRE. If we are talking about deploying to external customers then you need to have a support plan if this provisional API ever changes.

一个稳定的方法是创建一个根据此代码段在SWT中进行Shell,然后使用SWT_AWT桥接器,用于在您的应用程序中使用Frame:

A stable way to do this would be to create a Shell in SWT as per this snippet and then use the SWT_AWT bridge to get a Frame to use in your application:

java.awt.Frame frame = SWT_AWT.new_Frame(shell);

如果您只是部署到单个平台(如Windows),那么抛出一个SWT jar加上本土图书馆。如果您的目标是多个平台,那么这就变得很痛苦。

If you are just deploying to a single platform (like Windows) then tossing a single SWT jar plus the native library. If you are targeting multiple platforms then this becomes a pain.

所以这些是两种选择:处理AWTUtilities风险或使用SWT_AWT桥。

So those are the two choice: deal with the AWTUtilities risk or use the SWT_AWT bridge.

编辑:

一段时间过去了,Java 7已经用完了。有关官方支持的方法的文档,请参阅 Java Tutorials 。底部的如何实现形状窗口部分给出了一个示例。这当然假设你可以强制要求Java 7

Some time has passed and Java 7 is out. There is documentation on the officially supported way to accomplish this in the Java Tutorials. The section "How to Implement a Shaped Window" at the bottom gives an example. This of course assumes you can mandate Java 7

这篇关于我应该关注使用AWTUtilities.setWindowShape()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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