762 |
if (! visible || peer == null) |
if (! visible || peer == null) |
763 |
return false; |
return false; |
764 |
|
|
765 |
return parent == null ? true : parent.isShowing(); |
return parent == null ? false : parent.isShowing(); |
766 |
} |
} |
767 |
|
|
768 |
/** |
/** |
901 |
if (currentPeer != null) |
if (currentPeer != null) |
902 |
currentPeer.setVisible(true); |
currentPeer.setVisible(true); |
903 |
|
|
904 |
|
// The JDK repaints the component before invalidating the parent. |
905 |
|
// So do we. |
906 |
|
if (isShowing()) |
907 |
|
repaint(); |
908 |
// Invalidate the parent if we have one. The component itself must |
// Invalidate the parent if we have one. The component itself must |
909 |
// not be invalidated. We also avoid NullPointerException with |
// not be invalidated. We also avoid NullPointerException with |
910 |
// a local reference here. |
// a local reference here. |
911 |
Container currentParent = parent; |
Container currentParent = parent; |
912 |
if (currentParent != null) |
if (currentParent != null) |
913 |
{ |
currentParent.invalidate(); |
|
currentParent.invalidate(); |
|
|
currentParent.repaint(); |
|
|
} |
|
914 |
|
|
915 |
ComponentEvent ce = |
ComponentEvent ce = |
916 |
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); |
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN); |
946 |
ComponentPeer currentPeer=peer; |
ComponentPeer currentPeer=peer; |
947 |
if (currentPeer != null) |
if (currentPeer != null) |
948 |
currentPeer.setVisible(false); |
currentPeer.setVisible(false); |
949 |
|
boolean wasShowing = isShowing(); |
950 |
this.visible = false; |
this.visible = false; |
951 |
|
|
952 |
|
// The JDK repaints the component before invalidating the parent. |
953 |
|
// So do we. |
954 |
|
if (wasShowing) |
955 |
|
repaint(); |
956 |
// Invalidate the parent if we have one. The component itself must |
// Invalidate the parent if we have one. The component itself must |
957 |
// not be invalidated. We also avoid NullPointerException with |
// not be invalidated. We also avoid NullPointerException with |
958 |
// a local reference here. |
// a local reference here. |
959 |
Container currentParent = parent; |
Container currentParent = parent; |
960 |
if (currentParent != null) |
if (currentParent != null) |
961 |
{ |
currentParent.invalidate(); |
|
currentParent.invalidate(); |
|
|
currentParent.repaint(); |
|
|
} |
|
962 |
|
|
963 |
ComponentEvent ce = |
ComponentEvent ce = |
964 |
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); |
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN); |
1076 |
Component p = parent; |
Component p = parent; |
1077 |
if (p != null) |
if (p != null) |
1078 |
return p.getFont(); |
return p.getFont(); |
1079 |
else |
if (peer != null) |
1080 |
return new Font("Dialog", Font.PLAIN, 12); |
return peer.getGraphics().getFont(); |
1081 |
|
return null; |
1082 |
} |
} |
1083 |
|
|
1084 |
/** |
/** |
1404 |
peer.setBounds (x, y, width, height); |
peer.setBounds (x, y, width, height); |
1405 |
|
|
1406 |
// Erase old bounds and repaint new bounds for lightweights. |
// Erase old bounds and repaint new bounds for lightweights. |
1407 |
if (isLightweight() && isShowing ()) |
if (isLightweight() && isShowing()) |
1408 |
{ |
{ |
1409 |
if (parent != null) |
if (parent != null) |
1410 |
{ |
{ |
1411 |
Rectangle parentBounds = parent.getBounds(); |
Rectangle parentBounds = parent.getBounds(); |
1412 |
Rectangle oldBounds = new Rectangle(parent.getX() + oldx, |
Rectangle oldBounds = new Rectangle(oldx, oldy, oldwidth, |
1413 |
parent.getY() + oldy, |
oldheight); |
1414 |
oldwidth, oldheight); |
Rectangle newBounds = new Rectangle(x, y, width, height); |
|
Rectangle newBounds = new Rectangle(parent.getX() + x, |
|
|
parent.getY() + y, |
|
|
width, height); |
|
1415 |
Rectangle destroyed = oldBounds.union(newBounds); |
Rectangle destroyed = oldBounds.union(newBounds); |
1416 |
if (!destroyed.isEmpty()) |
if (!destroyed.isEmpty()) |
1417 |
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width, |
parent.repaint(0, destroyed.x, destroyed.y, destroyed.width, |
1735 |
if (peer != null) |
if (peer != null) |
1736 |
{ |
{ |
1737 |
Graphics gfx = peer.getGraphics(); |
Graphics gfx = peer.getGraphics(); |
1738 |
if (gfx != null) |
// Create peer for lightweights. |
1739 |
return gfx; |
if (gfx == null && parent != null) |
|
// create graphics for lightweight: |
|
|
Container parent = getParent(); |
|
|
if (parent != null) |
|
1740 |
{ |
{ |
1741 |
gfx = parent.getGraphics(); |
gfx = parent.getGraphics(); |
1742 |
Rectangle bounds = getBounds(); |
Rectangle bounds = getBounds(); |
1744 |
gfx.translate(bounds.x, bounds.y); |
gfx.translate(bounds.x, bounds.y); |
1745 |
return gfx; |
return gfx; |
1746 |
} |
} |
1747 |
|
gfx.setFont(font); |
1748 |
|
return gfx; |
1749 |
} |
} |
1750 |
return null; |
return null; |
1751 |
} |
} |
1885 |
* @see #repaint(long, int, int, int, int) |
* @see #repaint(long, int, int, int, int) |
1886 |
*/ |
*/ |
1887 |
public void repaint() |
public void repaint() |
1888 |
{ |
{ |
1889 |
if(!isShowing()) |
if(!isShowing()) |
1890 |
{ |
{ |
1891 |
Component p = parent; |
Component p = parent; |
3479 |
ComponentPeer tmp = peer; |
ComponentPeer tmp = peer; |
3480 |
peer = null; |
peer = null; |
3481 |
if (tmp != null) |
if (tmp != null) |
3482 |
tmp.dispose(); |
{ |
3483 |
|
tmp.hide(); |
3484 |
|
tmp.dispose(); |
3485 |
|
} |
3486 |
} |
} |
3487 |
|
|
3488 |
/** |
/** |
3809 |
{ |
{ |
3810 |
synchronized (getTreeLock ()) |
synchronized (getTreeLock ()) |
3811 |
{ |
{ |
3812 |
// Find this Component's top-level ancestor. |
// Find this Component's top-level ancestor. |
3813 |
Container parent = getParent (); |
Container parent = (this instanceof Container) ? (Container) this |
3814 |
|
: getParent(); |
3815 |
while (parent != null |
while (parent != null |
3816 |
&& !(parent instanceof Window)) |
&& !(parent instanceof Window)) |
3817 |
parent = parent.getParent (); |
parent = parent.getParent (); |
3818 |
|
|
3819 |
|
if (parent == null) |
3820 |
|
return; |
3821 |
|
|
3822 |
Window toplevel = (Window) parent; |
Window toplevel = (Window) parent; |
3823 |
if (toplevel.isFocusableWindow ()) |
if (toplevel.isFocusableWindow ()) |
3824 |
{ |
{ |