Skip to content

Commit fef1a1a

Browse files
committed
2 parents b73ee6f + 0222f45 commit fef1a1a

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
156 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ public void fillArc(int centerX, int centerY, int width, int height, int startAn
145145
}
146146

147147
private void doCirc(int left, int top, int diameter, boolean fill) {
148+
if (diameter <= 0)
149+
return;
148150
double r = diameter / 2f;
149151
ctx.beginPath();
150152
ctx.arc(left + r, top + r, r, 0, 2 * Math.PI, false);
@@ -157,6 +159,8 @@ private void doCirc(int left, int top, int diameter, boolean fill) {
157159

158160
private void doArc(double x, double y, double width, double height, double startAngle,
159161
double arcAngle, boolean fill) {
162+
if (width <= 0 || height <= 0)
163+
return;
160164
// boolean doClose = (arcAngle - startAngle == 360);
161165
ctx.save();
162166
{
@@ -230,6 +234,8 @@ private void doPoly(int[] axPoints, int[] ayPoints, int nPoints,
230234

231235

232236
public void drawRect(int x, int y, int width, int height) {
237+
if (width <= 0 || height <= 0)
238+
return;
233239
ctx.beginPath();
234240
ctx.rect(x, y, width, height);
235241
ctx.stroke();
@@ -245,11 +251,15 @@ public void fillPolygon(int[] axPoints, int[] ayPoints, int nPoints) {
245251

246252

247253
public void fillRect(int x, int y, int width, int height) {
254+
if (width <= 0 || height <= 0)
255+
return;
248256
backgroundPainted = true;
249257
ctx.fillRect(x, y, width, height);
250258
}
251259

252260
public void fill3DRect(int x, int y, int width, int height, boolean raised) {
261+
if (width <= 0 || height <= 0)
262+
return;
253263
Paint p = getPaint();
254264
Color c = getColor();
255265
Color brighter = c.brighter();
@@ -374,6 +384,8 @@ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
374384

375385
public boolean drawImage(Image img, int x, int y, int width, int height,
376386
ImageObserver observer) {
387+
if (width <= 0 || height <= 0)
388+
return true;
377389
backgroundPainted = true;
378390
if (img != null) {
379391
DOMNode imgNode = getImageNode(img);
@@ -406,6 +418,8 @@ public boolean drawImage(Image img, int x, int y, Color bgcolor,
406418

407419
public boolean drawImage(Image img, int x, int y, int width, int height,
408420
Color bgcolor, ImageObserver observer) {
421+
if (width <= 0 || height <= 0)
422+
return false;
409423
backgroundPainted = true;
410424
JSUtil.notImplemented(null);
411425
return drawImage(img, x, y, width, height, observer);

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,19 @@ public void stateChanged(ChangeEvent e) {
649649
@Override
650650
public void propertyChange(PropertyChangeEvent e) {
651651
String prop = e.getPropertyName();
652-
if (isDisposed && c.visible && prop == "ancestor"
653-
&& e.getNewValue() != null)
654-
setVisible(true);
652+
if (prop == "ancestor") {
653+
JSComponentUI parentui = this;
654+
/**
655+
* @j2sNative
656+
*
657+
* parentui = this.jc.parent && this.jc.parent.getUI &&
658+
* this.jc.parent.getUI();
659+
*/
660+
if (parentui != null)
661+
parentui.setTainted();
662+
if (isDisposed && c.visible && e.getNewValue() != null)
663+
setVisible(true);
664+
}
655665
propertyChangedCUI(prop);
656666
}
657667

0 commit comments

Comments
 (0)