1404 |
// Erase old bounds and repaint new bounds for lightweights. |
// Erase old bounds and repaint new bounds for lightweights. |
1405 |
if (isLightweight() && isShowing ()) |
if (isLightweight() && isShowing ()) |
1406 |
{ |
{ |
|
boolean shouldRepaintParent = false; |
|
|
boolean shouldRepaintSelf = false; |
|
|
|
|
1407 |
if (parent != null) |
if (parent != null) |
1408 |
{ |
{ |
1409 |
Rectangle parentBounds = parent.getBounds(); |
Rectangle parentBounds = parent.getBounds(); |
1413 |
Rectangle newBounds = new Rectangle(parent.getX() + x, |
Rectangle newBounds = new Rectangle(parent.getX() + x, |
1414 |
parent.getY() + y, |
parent.getY() + y, |
1415 |
width, height); |
width, height); |
1416 |
shouldRepaintParent = parentBounds.intersects(oldBounds); |
Rectangle destroyed = oldBounds.union(newBounds); |
1417 |
shouldRepaintSelf = parentBounds.intersects(newBounds); |
if (!destroyed.isEmpty()) |
1418 |
|
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width, |
1419 |
|
destroyed.height); |
1420 |
} |
} |
|
|
|
|
if (shouldRepaintParent && parent != null) |
|
|
parent.repaint(oldx, oldy, oldwidth, oldheight); |
|
|
if (shouldRepaintSelf) |
|
|
repaint(); |
|
1421 |
} |
} |
1422 |
|
|
1423 |
// Only post event if this component is visible and has changed size. |
// Only post event if this component is visible and has changed size. |
1824 |
*/ |
*/ |
1825 |
public void paint(Graphics g) |
public void paint(Graphics g) |
1826 |
{ |
{ |
1827 |
// Paint the heavyweight peer |
// This is a callback method and is meant to be overridden by subclasses |
1828 |
if (!isLightweight() && peer != null) |
// that want to perform custom painting. |
|
peer.paint(g); |
|
1829 |
} |
} |
1830 |
|
|
1831 |
/** |
/** |
1851 |
{ |
{ |
1852 |
// Tests show that the clearing of the background is only done in |
// Tests show that the clearing of the background is only done in |
1853 |
// two cases: |
// two cases: |
1854 |
// - If the component is lightwight (yes this is in contrast to the spec). |
// - If the component is lightweight (yes this is in contrast to the spec). |
1855 |
|
// or |
1856 |
// - If the component is a toplevel container. |
// - If the component is a toplevel container. |
1857 |
if (isLightweight() || getParent() == null) |
if (isLightweight() || getParent() == null) |
1858 |
{ |
{ |
1937 |
*/ |
*/ |
1938 |
public void repaint(long tm, int x, int y, int width, int height) |
public void repaint(long tm, int x, int y, int width, int height) |
1939 |
{ |
{ |
1940 |
// Handle lightweight repainting by forwarding to native parent |
if(!isShowing()) |
|
if (isLightweight() && parent != null) |
|
1941 |
{ |
{ |
1942 |
if (parent != null) |
Component p = parent; |
1943 |
parent.repaint(tm, x + getX(), y + getY(), width, height); |
if (p != null) |
1944 |
|
p.repaint(tm, x + getX(), y + getY(), width, height); |
1945 |
|
} |
1946 |
|
else |
1947 |
|
{ |
1948 |
|
ComponentPeer p = peer; |
1949 |
|
if (p != null) |
1950 |
|
p.repaint(tm, x, y, width, height); |
1951 |
} |
} |
|
else if (peer != null) |
|
|
peer.repaint(tm, x, y, width, height); |
|
1952 |
} |
} |
1953 |
|
|
1954 |
/** |
/** |
2009 |
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) |
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h) |
2010 |
{ |
{ |
2011 |
if ((flags & (FRAMEBITS | ALLBITS)) != 0) |
if ((flags & (FRAMEBITS | ALLBITS)) != 0) |
2012 |
repaint (); |
repaint(); |
2013 |
else if ((flags & SOMEBITS) != 0) |
else if ((flags & SOMEBITS) != 0) |
2014 |
{ |
{ |
2015 |
if (incrementalDraw) |
if (incrementalDraw) |
2019 |
long tm = redrawRate.longValue(); |
long tm = redrawRate.longValue(); |
2020 |
if (tm < 0) |
if (tm < 0) |
2021 |
tm = 0; |
tm = 0; |
2022 |
repaint (tm); |
repaint(tm); |
2023 |
} |
} |
2024 |
else |
else |
2025 |
repaint (100); |
repaint(100); |
2026 |
} |
} |
2027 |
} |
} |
2028 |
return (flags & (ALLBITS | ABORT | ERROR)) == 0; |
return (flags & (ALLBITS | ABORT | ERROR)) == 0; |
2320 |
// Some subclasses in the AWT package need to override this behavior, |
// Some subclasses in the AWT package need to override this behavior, |
2321 |
// hence the use of dispatchEventImpl(). |
// hence the use of dispatchEventImpl(). |
2322 |
dispatchEventImpl(e); |
dispatchEventImpl(e); |
|
if (peer != null && ! e.consumed) |
|
|
peer.handleEvent(e); |
|
2323 |
} |
} |
2324 |
|
|
2325 |
/** |
/** |
4783 |
* @param e the event to dispatch |
* @param e the event to dispatch |
4784 |
*/ |
*/ |
4785 |
|
|
4786 |
void dispatchEventImpl (AWTEvent e) |
void dispatchEventImpl(AWTEvent e) |
4787 |
{ |
{ |
4788 |
Event oldEvent = translateEvent (e); |
Event oldEvent = translateEvent (e); |
4789 |
|
|
4817 |
break; |
break; |
4818 |
} |
} |
4819 |
} |
} |
4820 |
processEvent (e); |
if (e.id == PaintEvent.PAINT || e.id == PaintEvent.UPDATE) |
4821 |
|
peer.handleEvent(e); |
4822 |
|
else |
4823 |
|
processEvent(e); |
4824 |
} |
} |
4825 |
} |
} |
4826 |
|
|