380 |
|
|
381 |
private TransferHandler transferHandler; |
private TransferHandler transferHandler; |
382 |
|
|
383 |
|
/** |
384 |
|
* A cached Rectangle object to be reused. Be careful when you use that, |
385 |
|
* so that it doesn't get modified in another context within the same |
386 |
|
* method call chain. |
387 |
|
*/ |
388 |
|
private static transient Rectangle rectCache; |
389 |
|
|
390 |
/** |
/** |
391 |
* A lock held during recursive painting; this is used to serialize |
* A lock held during recursive painting; this is used to serialize |
392 |
* access to the double buffer, and also to select the "top level" |
* access to the double buffer, and also to select the "top level" |
1521 |
protected void paintChildren(Graphics g) |
protected void paintChildren(Graphics g) |
1522 |
{ |
{ |
1523 |
Shape originalClip = g.getClip(); |
Shape originalClip = g.getClip(); |
1524 |
Rectangle inner = SwingUtilities.calculateInnerArea(this, new Rectangle()); |
Rectangle inner = SwingUtilities.calculateInnerArea(this, rectCache); |
1525 |
g.clipRect(inner.x, inner.y, inner.width, inner.height); |
g.clipRect(inner.x, inner.y, inner.width, inner.height); |
1526 |
Component[] children = getComponents(); |
Component[] children = getComponents(); |
1527 |
for (int i = children.length - 1; i >= 0; --i) |
for (int i = children.length - 1; i >= 0; --i) |
1529 |
if (!children[i].isVisible()) |
if (!children[i].isVisible()) |
1530 |
continue; |
continue; |
1531 |
|
|
1532 |
Rectangle bounds = children[i].getBounds(); |
Rectangle bounds = children[i].getBounds(rectCache); |
1533 |
Rectangle oldClip = g.getClipBounds(); |
Rectangle oldClip = g.getClipBounds(); |
1534 |
if (oldClip == null) |
if (oldClip == null) |
1535 |
oldClip = bounds; |
oldClip = bounds; |
1536 |
|
|
1537 |
Rectangle clip = oldClip.intersection(bounds); |
if (g.hitClip(bounds.x, bounds.y, bounds.width, bounds.height)) |
|
if (clip.isEmpty()) |
|
1538 |
continue; |
continue; |
1539 |
boolean translated = false; |
boolean translated = false; |
1540 |
try |
try |
1541 |
{ |
{ |
1542 |
g.setClip(clip.x, clip.y, clip.width, clip.height); |
g.clipRect(bounds.x, bounds.y, bounds.width, bounds.height); |
1543 |
g.translate(bounds.x, bounds.y); |
g.translate(bounds.x, bounds.y); |
1544 |
translated = true; |
translated = true; |
1545 |
children[i].paint(g); |
children[i].paint(g); |