# HG changeset patch # User alexp # Date 1299165799 -10800 # Node ID 4b9696d3b4930f619a4b97b394b077eb15282694 # Parent 041fad0cabfc3daf9f3b0e56372782984da23856 6653511: JComponent.safelyGetGraphics() may sometimes return null Reviewed-by: rupashka diff -r 041fad0cabfc -r 4b9696d3b493 jdk/src/share/classes/javax/swing/JComponent.java --- a/jdk/src/share/classes/javax/swing/JComponent.java Thu Mar 03 16:40:13 2011 +0300 +++ b/jdk/src/share/classes/javax/swing/JComponent.java Thu Mar 03 18:23:19 2011 +0300 @@ -5158,31 +5158,30 @@ } } } - try { - g = safelyGetGraphics(paintingComponent, c); - try { - if (hasBuffer) { - RepaintManager rm = RepaintManager.currentManager( - bufferedComponent); - rm.beginPaint(); - try { - rm.paint(paintingComponent, bufferedComponent, g, - paintImmediatelyClip.x, - paintImmediatelyClip.y, - paintImmediatelyClip.width, - paintImmediatelyClip.height); - } finally { - rm.endPaint(); + if ((g = safelyGetGraphics(paintingComponent, c)) != null) { + try { + if (hasBuffer) { + RepaintManager rm = RepaintManager.currentManager( + bufferedComponent); + rm.beginPaint(); + try { + rm.paint(paintingComponent, bufferedComponent, g, + paintImmediatelyClip.x, + paintImmediatelyClip.y, + paintImmediatelyClip.width, + paintImmediatelyClip.height); + } finally { + rm.endPaint(); + } + } else { + g.setClip(paintImmediatelyClip.x, paintImmediatelyClip.y, + paintImmediatelyClip.width, paintImmediatelyClip.height); + paintingComponent.paint(g); } + } finally { + g.dispose(); } - else { - g.setClip(paintImmediatelyClip.x,paintImmediatelyClip.y, - paintImmediatelyClip.width,paintImmediatelyClip.height); - paintingComponent.paint(g); - } - } finally { - g.dispose(); } } finally {