--- old/src/share/classes/javax/swing/JViewport.java 2014-02-03 18:16:46.000000000 +0400 +++ new/src/share/classes/javax/swing/JViewport.java 2014-02-03 18:16:46.000000000 +0400 @@ -39,6 +39,9 @@ import java.io.Serializable; +import sun.awt.image.OffScreenImage; +import sun.awt.image.SurfaceManager; +import sun.java2d.SunGraphics2D; /** @@ -754,8 +757,12 @@ if (!isOpaque()) { g.clipRect(0, 0, viewBounds.width, viewBounds.height); } + int scale = g instanceof SunGraphics2D ? + ((SunGraphics2D)g).surfaceData.getDefaultScale() : 1; - if (backingStoreImage == null) { + if (backingStoreImage == null || + SurfaceManager.getImageScale(backingStoreImage) != scale) + { // Backing store is enabled but this is the first call to paint. // Create the backing store, paint it and then copy to g. // The backing store image will be created with the size of @@ -763,7 +770,13 @@ // same size, otherwise when scrolling the backing image // the region outside of the clipped region will not be painted, // and result in empty areas. - backingStoreImage = createImage(width, height); + Window w = SwingUtilities.getWindowAncestor(this); + if (w instanceof JLightweightFrame) { + backingStoreImage = ((JLightweightFrame)w).createHiDPIImage(width, height); + ((OffScreenImage)backingStoreImage).setReturnLayoutSize(true); + } else { + backingStoreImage = createImage(width, height); + } Rectangle clip = g.getClipBounds(); if (clip.width != width || clip.height != height) { if (!isOpaque()) {