Skip to content

Commit a554ee4

Browse files
hansonrhansonr
authored andcommitted
JComponent .isRootPane bypasses paintImmediately clip for root pane
1 parent 750d713 commit a554ee4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public JPopupMenu getComponentPopupMenu() {
529529
if (parent instanceof JComponent) {
530530
return ((JComponent) parent).getComponentPopupMenu();
531531
}
532-
if (parent instanceof Window || parent instanceof JSApplet) {
532+
if (parent.isWindowOrJSApplet()) {
533533
// Reached toplevel, break and return null
534534
break;
535535
}
@@ -2747,8 +2747,7 @@ boolean processKeyBindings(KeyEvent e, boolean pressed) {
27472747
* component twice.
27482748
*/
27492749
Container parent = this;
2750-
while (parent != null && !(parent instanceof Window)
2751-
&& !(parent instanceof JSApplet)) {
2750+
while (parent != null && !parent.isWindowOrJSApplet()) {
27522751
if (parent instanceof JComponent) {
27532752
if (((JComponent) parent).processKeyBinding(ks, e,
27542753
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, pressed))
@@ -3836,7 +3835,7 @@ static final void computeVisibleRect(Component c, Rectangle visibleRect) {
38363835
Container p = c.getParent();
38373836
Rectangle bounds = c.getBounds();
38383837

3839-
if (p == null || p instanceof Window || p instanceof JSApplet) {
3838+
if (p == null || p.isWindowOrJSApplet()) {
38403839
visibleRect.setBounds(0, 0, bounds.width, bounds.height);
38413840
} else {
38423841
computeVisibleRect(p, visibleRect);
@@ -4000,7 +3999,7 @@ public Rectangle getVisibleRect() {
40003999
public Container getTopLevelAncestor() {
40014000
// See also JSComponent getTopInvokableAncestor
40024001
for (Container p = this; p != null; p = p.getParent()) {
4003-
if (p instanceof Window || p instanceof JSApplet) {
4002+
if (p.isWindowOrJSApplet()) {
40044003
return p;
40054004
}
40064005
}
@@ -4440,8 +4439,7 @@ void _paintImmediately(int x, int y, int w, int h) {
44404439
}
44414440
}
44424441
Component child;
4443-
for (c = this, child = null; c != null && !(c instanceof Window)
4444-
&& !(c instanceof JSApplet); child = c, c = c.getParent()) {
4442+
for (c = this, child = null; c != null && !c.isWindowOrJSApplet(); child = c, c = c.getParent()) {
44454443
JComponent jc = (c instanceof JComponent) ? (JComponent) c : null;
44464444
path.add(c);
44474445
if (!ontop && jc != null && !jc.isOptimizedDrawingEnabled()) {
@@ -4558,13 +4556,13 @@ void _paintImmediately(int x, int y, int w, int h) {
45584556
rm.endPaint();
45594557
}
45604558
} else {
4561-
// SwingJS not clipping for better performance
4562-
g.setClip(paintImmediatelyClip.x, paintImmediatelyClip.y,
4559+
// For some reason painting of the root pane causes a persistent clip in AWT.
4560+
4561+
// SwingJS early on was not clipping for better performance
4562+
if (!isRootPane)
4563+
g.setClip(paintImmediatelyClip.x, paintImmediatelyClip.y,
45634564
paintImmediatelyClip.width, paintImmediatelyClip.height);
45644565

4565-
// g.setClip(paintImmediatelyClip.x,paintImmediatelyClip.y,
4566-
// paintImmediatelyClip.width,paintImmediatelyClip.height);
4567-
45684566
// this sequence assures that if the developer called
45694567
// jpanel.repaint() and then draws on the background,
45704568
// the JPanel's background is made transparent

0 commit comments

Comments
 (0)