Should I be interested in using AWTUtilities.setWindowShape ()?

I use the AWTUtilities class in my application to create custom window shapes. As far as I know, there is no other way to do this. This is a requirement.

The javadoc generation gives me this error:

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

What exactly does this mean? I can use it, but it can stop working with any release? Why put it? More importantly, and the real question is, if the Sun chooses it, will it replace it with another way to do the same? What is this warning for?

Suppose I could just check for the AWTUtilities class before calling the code. But this is just unpleasant if I do not need to do this.

Does anyone have experience with similar classes? Were they eventually accepted in the API, and the warning was removed or replaced with another way to do the same? Do I need to worry about this?

FYI, I read the following:

How to distribute AWTUtilities

+4
source share
2 answers

The Oracle documentation says:

Note. The com.sun.awt.AWTUtilities class is not part of the officially supported API and is displayed as an implementation detail. The API is intended only for limited use outside the main platform. It can change dramatically between update updates and can even be removed or moved to some other packages or classes. The class should be used through Java Reflection. A supported and open API will appear in the next major version of the JDK.

JDK 7 is a long time coming, so maybe a little. Should you use this risk management question that only your company can answer. If we are talking about an internal application where the installed JRE can be guaranteed, then you will not have a problem, because you can guarantee JRE compatibility. If we are talking about deploying to external clients, then you need to have a support plan if this temporary API ever changes.

A sustainable way to do this would be to create a Shell in the SWT according to this snippet , and then use the SWT_AWT bridge to get the Frame for use in the application:

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

If you just deploy on the same platform (for example, on Windows), then drop one SWT-jar plus an integrated library. If you target multiple platforms, it becomes a pain.

So, these are two options: deal with the risk of AWTUtilities or use the SWT_AWT bridge.

EDIT:

Some time has passed and Java 7 is not working. There is documentation on the officially supported way to do this in the Java Tutorials . For example, in the "How to Implement a Molded Window" section below. This of course assumes that you can instruct Java 7

+4
source

You do not need a new Frame object, you can use

 this.setShape(shape); 

or your frame name like this

 Frame1.setShape(shape); 

many AWT methods have been applied to java.awt.Frame.

0
source

All Articles