Skip to content

Commit 227b8b2

Browse files
hansonrhansonr
authored andcommitted
fixes for paint path
1 parent b950165 commit 227b8b2

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public Graphics getGraphics() {
273273
@Override
274274
public void addNotify() {
275275
if (秘paintsSelf() && ui != null) // BoxFiller will not have a ui?
276-
((JSComponentUI) ui).clearPaintPath();
276+
((JSComponentUI) ui).clearPaintPath();
277277
super.addNotify();
278278
}
279279

sources/net.sf.j2s.java.core/src/swingjs/a2s/Canvas.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.awt.Dimension;
55
import java.awt.Graphics;
66
import java.awt.GraphicsConfiguration;
7+
import java.awt.JSComponent;
78

89
public class Canvas extends Panel {
910

@@ -18,6 +19,7 @@ public Canvas() {
1819
秘paintClass = 秘updateClass = /**@j2sNative C$ || */null;
1920
}
2021

22+
2123
@Override
2224
public Dimension getPreferredSize() {
2325
// must bypass JComponent here because we subclass Panel

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ public void setDraggable(JSFunction f) {
472472
* indicates not to add it to the DOM
473473
*/
474474
private boolean isPaintedOnly;
475+
476+
/**
477+
* container is between the HTML5 canvas and a component that paints itself
478+
*/
479+
private boolean inPaintPath;
475480

476481

477482
/**
@@ -3386,7 +3391,7 @@ public void setBackground(Color c) {
33863391
}
33873392

33883393
private Color backgroundColor;
3389-
3394+
33903395
protected void setBackgroundImpl(Color color) {
33913396
// Don't allow color for Menu and MenuItem. This is taken care of by
33923397
// jQuery
@@ -3413,7 +3418,7 @@ private void checkTransparent() {
34133418
// Here we keep it simple and do the change immediately.
34143419
//
34153420

3416-
if (domNode != null && (cellComponent != null || !c.isOpaque()))
3421+
if (inPaintPath || domNode != null && (cellComponent != null || !c.isOpaque()))
34173422
setTransparent();
34183423
}
34193424

@@ -3462,6 +3467,9 @@ protected void setBackgroundDOM(DOMNode node, Color color) {
34623467
public void clearPaintPath() {
34633468
JSComponent c = jc;
34643469
while (c != null) {
3470+
((JSComponentUI) c.ui).inPaintPath = true;
3471+
3472+
c.秘setPaintsSelf(JSComponent.PAINTS_SELF_ALWAYS);
34653473
((JSComponentUI) c.ui).setTransparent();
34663474
c = c.getParent();
34673475
}

0 commit comments

Comments
 (0)