Check for a behavior change on Window setBackground method

This rule flags Java code with calls to the java.awt.Window setBackground() method. This method is flagged because there is a behavior change associated with it. According to the Java SE 7 and JDK 7 Compatibility documentation, this method can now throw an UnsupportedOperationException. This exception is thrown when running on systems that do not support translucency visual effects when applying a non-opaque background color to the window.

If the application will only run on Java 7 (and higher), your code can use the new GraphicsDevice.isWindowTranslucencySupported method to check for support before supplying a non-opaque background color. Alternatively, if your application must run on Java 7 and earlier levels, you can opt to handle the UnsupportedOperationException to code a recovery action should a failure arise setting the window background.

This rule will not flag calls to setBackground if UnsupportedOperationException or its superclass exceptions are already handled.

For additional information related to this change: