RFR: 8282526: Default icon is not painted properly

Jeremy duke at openjdk.java.net
Sun Mar 13 23:31:44 UTC 2022


On Sun, 13 Mar 2022 21:06:24 GMT, Alexander Zuev <kizune at openjdk.org> wrote:

> Detect the situation where we do need to perform interpolation during ImageIcon
> painting and set a hint to the rendering to perform bicubic approximation so
> image details are preserved during transition.

src/java.desktop/share/classes/javax/swing/ImageIcon.java line 463:

> 461:         if (hintChanged) {
> 462:             ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_INTERPOLATION,
> 463:                     oldHint == null ? RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR : oldHint);

This might be a rookie question:

When it comes to modifying and restoring a Graphics, I've seen two common patterns:
A. Call `newG = g.create()` and later `newG.dispose()`
B. Call `g.setX(newValue)` and then call `g.setX(oldValue)` later

Is there guidance on when to use which? Or is one always preferred?

-------------

PR: https://git.openjdk.java.net/jdk/pull/7805



More information about the client-libs-dev mailing list